Ajax Synchronous Callbacks

I have pageTest.html in a local folder, is service.ashx called on this page? i = ... (which return param pass incremented +1) followed by Ajax code:

.
.
getIncr: function(parameters, success){
       $.ajax({
               async: false, 
               type: methodType,
               url: getTarget,
               data: "n="+parameters,
               dataType:"jsonp",
               success: success
             });
    }
.
.

The html page calls this function for time m (with script ..):

  .    
  var start = function(){
  .
  .
  var val = 0;
  .      
  .
  for(i=0; i<m; i++)
  {
      Foo.getIncr(val, function(returned_n){
          val = returned_n;
      });

  }

};

When the page loads, calls are made in "Asynchronous mode", but I set " async: false " to Ajax. I read about this problem and found the reason, that is, Ajax cannot synchronize the call from page.html to service.ashx if there is one in another domain. Is there a solution for making a Synch call in page.html to this service.ashx (in another domain)?

+3
2

, , JSONP. , , - , - " script". , jQuery javascript, script.

, jQuery, JSONP, JSONP, , . .

, $.ajax . , , , , .

+6

XMLHttpRequest. , .

, , JSON ( jsonp), , , script. , jQuery ( jQuery, , ?):

http://docs.jquery.com/Release:jQuery_1.2/Ajax#Cross-Domain_getJSON_.28using_JSONP.29

+1

Source: https://habr.com/ru/post/1704519/


All Articles