-1

synchronous ajax is not working:

        var rslt = false;

            $.ajax({
                async: false,
                url: url,
                dataType: "json",
                success: function(data) {                      
                     rslt = true;                      
                }                      
                });


            document.write(rslt);

rslt still displays as false.

I am out of ideas...

Shing Zhao
  • 39
  • 1
  • 6
  • 3
    Maybe you're getting an ERROR. You don't have any error detection here – Ian Aug 21 '13 at 21:04
  • possible duplicate of [jQuery: Performing synchronous AJAX requests](http://stackoverflow.com/questions/6685249/jquery-performing-synchronous-ajax-requests) – Ian Aug 21 '13 at 21:05
  • if you weren't using `document.write`, you wouldn't feel the need to use synchronous AJAX. The disease is bad, but so is the cure. – John Dvorak Aug 21 '13 at 21:29
  • i don't think you should get callbacks with sync... – dandavis Aug 21 '13 at 21:34

1 Answers1

0

You could inform if it's a GET or a POST, as you're not passing anything, I think its a get, sou set the type to 'GET'

This should work:

var rslt = false;

            $.ajax({
                async: false,
                type: 'GET',
                dataType: 'json',
                url: url,
                success: function(data) {                      
                     rslt = true;                      
                }                      
            });


document.write(rslt);
Rômulo Spier
  • 231
  • 1
  • 11