[jQuery] Synchronous JSONP
<span style="font-family: trebuchet ms,sans-serif;">Right now in 1.2.1 the JSONP method uses an asynchronous call to do it's thing.</span><br style="font-family: trebuchet ms,sans-serif;"><span style="font-family: trebuchet ms,sans-serif;">
This sometimes causes a problem when we are sending a call about a "click" event on a link. The page unloads before the JSONP is finished.</span><br style="font-family: trebuchet ms,sans-serif;"><br style="font-family: trebuchet ms,sans-serif;">
<span style="font-family: trebuchet ms,sans-serif;">Changing it to be optional (async or synchronous) helps fix that problem.</span><br style="font-family: trebuchet ms,sans-serif;"><br style="font-family: trebuchet ms,sans-serif;">
<span style="font-family: trebuchet ms,sans-serif;">Code we used inside jQuery (with a param call to .ajax)
<br style="font-family: trebuchet ms,sans-serif;"></span><span style="font-family: courier new,monospace;">/* If the request is not async, we need to wait for the script to l
</span><span style="font-family: courier new,monospace;">oad before returning. */ </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"></span><span style="font-family: courier new,monospace;">
else if (!s.async) { </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> var done = false; </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
// Attach handlers for all browsers </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> script.onload = script.onreadystatechange = function(){ </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if ( !done && (!this.readyState || </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> this.readyState
== "loaded" || this.readyState == "complete") ) { </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> } </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }; </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> } </span><br style="font-family: trebuchet ms,sans-serif;">
<br style="font-family: trebuchet ms,sans-serif;"><span style="font-family: trebuchet ms,sans-serif;"><span style="background-color: rgb(255, 255, 153);">QUESTION:</span> Putting this directly into our copy of jQuery is probably a bad idea.
<b>How can this be turned into a plugin?</b></span><br style="font-family: trebuchet ms,sans-serif;"><br style="font-family: trebuchet ms,sans-serif;"><span style="font-family: trebuchet ms,sans-serif;">Thanks much,</span>
<br style="font-family: trebuchet ms,sans-serif;"><br style="font-family: trebuchet ms,sans-serif;"><span style="font-family: trebuchet ms,sans-serif;">Glen</span><br style="font-family: trebuchet ms,sans-serif;">