Bug Tracker

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#14816 closed bug (notabug)

doing cross-domain syncronous ajax request within a jsonp ajax request - syncronous flag is not respected for the internal requests

Reported by: tobias.hein@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.10.1
Keywords: Cc:
Blocked by: Blocking:

Description

Hi Guys,

we came across a jQuery problem when doing the following

  • do an ajax request from mydomain.com
  • get a jsonp-Response like
    $.ajax({
    url: "anotherdomain.com/someother/MyObject.js",
    dataType: "script",
    cache: true,
    async: false
    });
    
    var myObject = new MyObject();
    

Here get an error because the MyObject.js is not loaded although the ajax request is marked as with async:false.

We tried to debug the problem and we also read the manual which says, that jsonp-Requests always will be called with async:true.

but in this case only the first request is a jsonp-Request. so we guess jQuery should respect the configuration of non-jsonp-Requests by e.g. resetting the transportation to non-jsonp.

We found this behavior in jQuery-Version 1.8.3 up to 1.10.1

Change History (3)

comment:1 Changed 6 years ago by dmethvin

Resolution: notabug
Status: newclosed

The docs for async say: " Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation."

comment:2 Changed 6 years ago by Tobias Hein <tobias.hein@…>

Hi Guys,

sorry for the embarrasment regarding my bug report. it seems as i has not pointed out the problem well. as i mentioned, we read the manual and there is no doubt that

Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation."

Thats not our problem. the problem is, that we fetch javascript code by a jsonp request. this javascript code executes an independent ajax request. this ajax-request should be executed synchronously - but instead, because its code has been loaded by an asychnronous "jsonp"-request, it is also exectuted asynchronously.

comment:3 Changed 6 years ago by anonymous

In your example, you're using a cross-domain "script" request which by its very nature cannot be synchronous since it must use script tag injection.

https://github.com/jquery/jquery/blob/master/src/ajax/script.js#L33-L35

Note: See TracTickets for help on using tickets.