what is the function of “ajaxObj.” ? could u give me an example..
if(ajaxObj.... )//i don't understand in this part
{
document.getElementById("divResult").innerHTML = ajaxObj.responseText;
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s very hard if not impossible to answer this question on the basis of the information you’ve given, but: Perhaps you’re talking about the
XMLHttpRequestobject. It’s job is to send a GET or POST (or sometimes other verbs) request to the server and receive the response, without doing a page refresh. For instance, when you submit a comment on a question or answer here on StackOverflow, an XHR (as they’re frequently called) is used to send your comment to the server rather than requiring the entire page to be reloaded.XHR isn’t very hard to use directly, but it’s even easier to do this if you use a library like Prototype, jQuery, Closure, or any of several others that will handle some browser idiosyncracies for you and generally make the API a bit simpler.
Edit Based on your updated question:
My guess was probably correct:
ajaxObjis probably an instance ofXMLHttpRequest, sinceresponeTextis one of theXMLHttpRequestproperties. (Or it might be a PrototypeAjax.Response, as they used the same name; other frameworks may have done something similar.)What that code is doing is checking to see if the
ajaxObjvariable refers to something and, if so, the code replaces the content of thedivResultdiv with the markup that the server sent back in response to the request (looking up the element by ID and then setting itsinnerHTMLproperty).