title: Callback function for JSONP with jQuery AJAX
body: <p>I didn't quite understand how to work with the callback for the ajax function of jQuery.</p>
  
  <p>I have the following code in the JavaScript:</p>
  
  <pre><code>try {
      $.ajax({
          url: 'http://url.of.my.server/submit?callback=?',
          cache: false,
          type: 'POST',
          data: $("#survey").serialize(),
          dataType: "jsonp",
          timeout: 200,
          crossDomain: true,
          jsonp: 'jsonp_callback',
          success: function (data, status) {
              mySurvey.closePopup();
          },
          error: function (xOptions, textStatus) {
              mySurvey.closePopup();
          }
      });
  } catch (err) {
      mySurvey.closePopup();
  }
  </code></pre>
  
  <p>And on the server side (AppEngine / Python) I get the value of the callback parameter and respond with</p>
  
  <pre><code>self.response.headers['Content-Type'] = 'application/json; charset=utf-8'
  self.response.out.write(callback + '({"msg": "ok"});')
  </code></pre>
  
  <p>But then I get an <code>"Error: jQuery152042227689944248825_1317400799214 is not a function"</code> in the browser console.</p>
  
  <p>What is the proper way to handle this? Right now I get the results that I need, but the fact that I know it's not right is bothering me.</p>