Glad to know you solved it.
On Apr 23, 4:59 pm, "s.ross" <[EMAIL PROTECTED]> wrote: > On Apr 23, 2008, at 1:27 AM, Diego A. wrote: > > > > > Is the new link by any chance being inserted within the trigger > > itself? (doesn't seem like it would work because the code takes the > > href attribute from the trigger itself, not the link within it, but it > > could cause something weird to happen). > > Diego, you're pretty much on target here. I posted a follow-up > at:http://groups.google.com/group/jquery-en/browse_thread/thread/2cb9e3e... > that explains what the problem was. What I wound up using was event > bubbling so I could replace something inside the span without > affecting the binding between the handler and the element. > > > Other than that, are use using event delegation or live query or some > > other way of binding events that is automatically executing the > > ajaxBind function on the new link when it is inserted? > > > On Apr 22, 9:51 pm, "s.ross" <[EMAIL PROTECTED]> wrote: > >> I'm having a strange problem using $.ajax. Better to illustrate with > >> the code: > > >> function ajaxBind(trigger) { > >> trigger.click(function(){ > >> $.ajax({ > >> type: "POST", > >> url: $(this).attr('href'), > >> data: { > >> 'authenticity_token': $ > >> ('input[name=authenticity_token]').val() > >> }, > >> dataType: 'json', > >> beforeSend: function(xhr) { > >> xhr.setRequestHeader("Accept", "application/json"); > >> }, > >> // json contains id and partial keys > >> success: function(json) { > >> $('#task' + json['task']).html(json['partial']); > >> } > >> }); > >> return false; > >> }); > > >> } > > >> When the DOM element "trigger" is clicked, a request to the server is > >> issued and the JSON response comes back. Hokey, dokey. The response > >> is > >> an html link. Something along the lines of: > > >> partial: "link in html that google would strip out anyway" > > >> This gets inserted using the html() function, as you see in the > >> success: part of the $.ajax call, and all is well until I click on > >> the > >> new link. Then the link is interpreted as a request to open a > >> document > >> of type application/json. Firebug doesn't reveal anything unusual > >> about the inserted HTML. Does anyone see the problem here? > > >> Thanks

