Ajax jquery confusion

This is probably straight forward, but I am a newbie and I need help! If I make an Ajax request that, when it successfully replaces the DOM section with other data, how do I make the new data available to jQuery?

0


a source to share


3 answers


The data will be available in the parameter that you pass to the callback function

$.ajax( {
type:'Get',
url:'http://mysite.com/mywebservice',
sucess:function(data) {
 alert(data);
}

})

      

Which you can also express with Ajax shorthand get



$.get('http://mysite.com/mywebservice', function (data) {
 alert(data);
});

      

And if you mean how to access data after you've put it into the DOM, then it will be automatically available because it will become part of the DOM.

+1


a source


In the callback function provided for the ajax request, you will access the data. From there, you can replace part of the DOM with it and / or store it elsewhere (global variable, etc.).



0


a source


The elements in the replaced scope are of course unrelated to event handlers, unless you are using the new live () jquery 1.3 events.

0


a source







All Articles