Search code examples
javascriptprototypejs

Ajax not working in synchronous manner


I am using prototype.js for making Ajax request. Everything was working fine till I changed asynchronous to false (As I want to make synchronous requests). Following are the few lines from my code.

    var commOptions = {
                contentType: 'text/xml',
                method: 'post',
                asynchronous: true,
                evalJS: false,
                evalJSON: false
            };   
   sProxy_Url = sUrl;  
   new Ajax.Request(sProxy_Url, commOptions);   

If I change asynchronous to false then Ajax do not work. Am I missing anything ?


Solution

  • Honestly I don't see what's not working, I even got the response in javascript to make sure:

    var commOptions = {
                    contentType: 'text/xml',
                    method: 'post',
                    asynchronous: false,
                    evalJS: false,
                    evalJSON: false
                };   
    
       var a = new Ajax.Request("/", commOptions);
    console.log( a.transport.responseText.length ); //16898
    

    http://jsfiddle.net/HRu78/1/