Reputation: 2126
I am messing around with Jquery AJAX couple of day's and on the net i found this code below:
I know what this code does but i am having trouble understanding some parts of it. For example I don't know what (url) is. I know it is a function parameter but don't know what it represent or contains. I also don't understand what is responseText inside this function. So i am hoping that someone can explain those parameters to me. Sorry for the noob question! And thank you!!
example_ajax_request(url) {
$('#example-placeholder').load(url, "",
function(responseText, textStatus, XMLHttpRequest) {
if(textStatus == 'error') {
$('#example-placeholder').html('<p>There was an error making the AJAX request</p>');
}
}
);
}
Upvotes: -1
Views: 66
Reputation: 27437
url is the url to wich the request is being sent. responseText holds the server's response.
In your example, the url is a var that must have been set before. A string could also be passed to the function, like 'http://example.url'
The responseText var will be set once the request returns from the server and will hold any data rendered by the server.
Upvotes: 1
Reputation: 95022
url
is the url that you are loading content from, and responseText
contains the text content that was returned from the ajax request. You do not need to do anything with responseText
because it is automatically being set as the content of the #example-placeholder
element.
Upvotes: 4