Glen, I think I understand what you are saying, but not truly sure what full approach is. It sounds like you want to send some data to another site when the user clicks a link, like maybe the href of the link clicked. Not sure if the is considered JSONP, and bare with me on this one, but what I am doing with a app at work is something like below:
$('a').click(function(){ var href = $(this).attr('href'); var c = document.createElement('link'); c.type = 'text/css'; c.media = 'screen'; c.rel = 'stylesheet'; c.href = 'http://www.thisurl.com/?click='+href; $('head')[0].appendChild(c); setTimeout(function(){ location.href = href; }, 1000); return false; }); This is a scaled down version of what I am doing, a caveat is that if the page takes too long to load, the params never get passed. This approach is only assuming that nothing is being echoed out on the "thisurl.com" end. On 1/8/08, Glen Lipka <[EMAIL PROTECTED]> wrote: > > I think my thought process on this was messed up anyway. > Here is the use situation. We are using JSONP to send activity on pages > to avoid cross-site scripting problems. One of those activities is clicking > on a link. > > The problem is that the JSONP is asynchronous so that when the link is > clicked, the page unloads before the JSONP has a chance to do it's thing. > > What is the best way of allowing the JSONP to do it's thing and pause the > unload of the page long enough for it to work? > > Glen > > > On Jan 8, 2008 1:37 PM, Benjamin Sterling < > [EMAIL PROTECTED]> wrote: > > > Glen, > > I have never done it, but I say a while back that you can use the > > jQuery.extend method to overwrite a default method. I will see if I can > > dig that up, but that may point you in the right direction in the mean time. > > > > > > > > On 1/8/08, Glen Lipka <[EMAIL PROTECTED]> wrote: > > > > > > Right now in 1.2.1 the JSONP method uses an asynchronous call to do > > > it's thing. > > > 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. > > > > > > Changing it to be optional (async or synchronous) helps fix that > > > problem. > > > > > > Code we used inside jQuery (with a param call to .ajax) > > > > > > /* If the request is not async, we need to wait for the script to l oad > > > before returning. */ > > > else if (!s.async) { > > > var done = false; > > > // Attach handlers for all browsers > > > script.onload = script.onreadystatechange = function(){ > > > if ( !done && (!this.readyState || > > > this.readyState == "loaded" || this.readyState == "complete") > > > ) { > > > } > > > }; > > > } > > > > > > QUESTION: Putting this directly into our copy of jQuery is probably a > > > bad idea. *How can this be turned into a plugin?* > > > > > > Thanks much, > > > > > > Glen > > > > > > > > > > > -- > > Benjamin Sterling > > http://www.KenzoMedia.com > > http://www.KenzoHosting.com > > http://www.benjaminsterling.com > > > -- Benjamin Sterling http://www.KenzoMedia.com http://www.KenzoHosting.com http://www.benjaminsterling.com