title: Error in response in Jquery Ajax request
body: <p>I have a script which is posting some form data to a Quickbase and I'm getting what the browser interprets as JavaScript error in Quickbase's XML response. Right now, the data is properly being recorded in Quickbase but I can't seem to suppress the parsing error. Additionally, I have no access to server-side languages - just client-side JavaScript.</p>
  
  <p>Here's the Ajax code:</p>
  
  <pre><code>myObject.prototype.get = function (url, formdata, context, callback) {
      var options = {
          "url": url,
          "type": "GET",
          "data": formdata,
          "context": context,
          "complete": callback,
          "dataType" : "jsonp",
          "dataFilter" : function (data,type) { 
              alert(data);
          }
      };
      jQuery.ajax(options);
  };
  </code></pre>
  
  <ul>
  <li>url =  <a href="https://www.quickbase.com/db/xxxxxxx?act=API_AddRecord" rel="nofollow noreferrer">https://www.quickbase.com/db/xxxxxxx?act=API_AddRecord</a></li>
  <li>data = the data collected from the form the user fills out</li>
  </ul>
  
  <p>The URL that gets generated ends up looking like this:
  <a href="https://www.quickbase.com/db/xxxxxx?act=API_AddRecord&amp;apptoken=xxxxxxxx&amp;callback=jsonp1284044371978&amp;_fid_11=www.domain.com&amp;_fid_12=xxxxx&amp;_fid_17=xxxxxx&amp;_fid_6=xxxxx&amp;_fid_10=xxxxxxxx&amp;=No+Thanks" rel="nofollow noreferrer">https://www.quickbase.com/db/xxxxxx?act=API_AddRecord&amp;apptoken=xxxxxxxx&amp;callback=jsonp1284044371978&amp;_fid_11=www.domain.com&amp;_fid_12=xxxxx&amp;_fid_17=xxxxxx&amp;_fid_6=xxxxx&amp;_fid_10=xxxxxxxx&amp;=No+Thanks</a></p>
  
  <p>Because I'm posting across domains, I'm using the JSONP datatype and that seems to be working correctly until I get this XML response:</p>
  
  <pre><code>&lt;?xml version="1.0" ?&gt;
  &lt;qdbapi&gt;
      &lt;action&gt;API_AddRecord&lt;/action&gt;
      &lt;errcode&gt;0&lt;/errcode&gt;
      &lt;errtext&gt;No error&lt;/errtext&gt;
      &lt;rid&gt;740&lt;/rid&gt;
      &lt;update_id&gt;1284045768176&lt;/update_id&gt;
  &lt;/qdbapi&gt;
  </code></pre>
  
  <p>Firebug then throws this error:</p>
  
  <p><strong>"unterminated regular expression literal"</strong></p>
  
  <pre><code>&lt;errcode&gt;0&lt;/errcode&gt;\n
  </code></pre>
  
  <p>You'll see that I've tried to act on the response with the <code>dataFilter</code> setting but I can't even get it to fire. The script runs and nothing gets alerted. </p>
  
  <p>It might be worth noting that I don't care about the response from the Quickbase server; I just want the error to go away since I'm not doing anything with the response.</p>
  
  <p><strong><em>Edit</em></strong>
  Vivin Paliath pointed out below that the reason I get the error is because the browser is looking for JavaScript to be returned but since QuickBase won't return anything but XML, I need a way to either destroy or alter the response
  <strong>* End Edit *</strong></p>
  
  <p>Can anyone tell me:</p>
  
  <ol>
  <li>Why the dataFilter never fires?</li>
  <li>How can I suppress this error?</li>
  </ol>
  
  <p>Thanks everyone</p>
  
  <h2>----------</h2>
  
  <p>Update: I'm marking Vivin Paliath's answer as accepted because they are correct: you can't do it this way without access to a proxy or server-side languages. I decided to go in a different direction. This is what I did.</p>
  
  <ol>
  <li><p>Create a hidden iframe on the page</p>
  
  <p><code>&lt;iframe id="myHiddenIframe" name"myHiddenIframe" src="#" height="1" width="1" style="display:hidden"&gt;&lt;/iframe&gt;</code></p></li>
  <li><p>Upon the submission of <code>&lt;form id="myForm"&gt;</code>, I collected and serialized the answers :</p>
  
  <p><code>var myAnswers = $('#myForm').serialize();</code></p></li>
  <li><p>Built the URL I want to use:</p>
  
  <p><code>var myUrl = 'https://www.quickbase.com/db/xxxxxxx?act=API_AddRecord&amp;apptoken=xxxxxxxx&amp;'+myAnswers;</code></p></li>
  <li><p>Pushed the iframe to the URL I created
  <code>$('#myHiddenIframe').attr('src', myUrl);</code></p></li>
  </ol>
  
  <h2>----------</h2>