0

Here's the code:

    $(document).ready(function() {
        $().ajaxStart(function(){
            alert("in ajaxStart")
            //tried removing $.blockUI( below, same thing. don't see alert
            //$.blockUI({ message: '<h1><img src="images/ajax-loader.gif" /> Running query...</h1>' }); 
        });
        $().ajaxStop(function(){
            $.unblockUI()
        });
    ...
        $("#frmQUERYSUBMIT").submit(function(e) {
    ...
            $.ajax({
                type: "POST",
              url:    '/execquery/' + jsonQuery,
              //datatype: JSON, //original, incorrect
              datatype: "json", //still get same problem with correct usage
              success: function(data, textStatus) {
                          $("#status p").html(data);
                       },
              async:   true
            });          
    ...
        });
    });

In 1.3.2, this worked fine, reached the server, gave me back the data I expected. When I upgraded to 1.7.1, it works once (per opening of browser), but all subsequent executions do nothing. If I step thru the code in firebug, it shows it going from line to line every time, but only actually does something the first time. Also, in 1.7.1, $().ajaxStart( is also only run the first time, not any subsequent times.

TIA

EDIT: I had originally posted that my server logs showed no connection on subsequent attempts. This was an error. The logs show that a connection is made, and a response given. It just doesn't show up in the browser.

EDIT: FWIW, in 1.3.2, the data comes back as "{"queries":{"f.sp":{"1d":{"show_results":{"19820611":-2.6893769610040343,..."; but in 1.7.1, it comes back as Document, and says that the type is application/xml

davej
  • 1,350
  • 5
  • 17
  • 34
  • 2
    `datatype: JSON`: Where do you define the `JSON` variable? And `datatype` is not a valid option. – Felix Kling Dec 12 '11 at 12:39
  • `datatype: JSON` should be changed to `dataType: "json"`. `async=true` isn't required as `true` is `async`'s default value. – jabclab Dec 12 '11 at 12:54
  • http://api.jquery.com/jQuery.ajax/ documents datatype option. But the code I showed is wrong, should be dataType: "json". I changed it, but it still doesn't work after first go. No errors in firebug. – davej Dec 12 '11 at 13:00

2 Answers2

1

JSON is not a valid datatype, try giving datatype: 'json'

dku.rajkumar
  • 18,414
  • 7
  • 41
  • 58
  • Thanks, yes, I did try that (and edited my original post), but it didn't make a difference. – davej Dec 12 '11 at 13:09
0

Issue #1, the data not being available to javascript was solved by this: https://stackoverflow.com/a/250245/403748,

beforeSend: function(x) {
  if(x && x.overrideMimeType) {
   x.overrideMimeType("application/j-son;charset=UTF-8");
  }
 },

and issue #2 was solved by https://stackoverflow.com/a/4034337/403748

$(document).ajaxStart(

instead of $().ajaxStart(

Sorry for the time-waster...

Community
  • 1
  • 1
davej
  • 1,350
  • 5
  • 17
  • 34