$.ajax({
type: "GET",
url: "some.php",
data: "name=John&location=Boston",
success: function(msg){
alert( "Success" );
}
error: function(emsg){
| alert(xhr.statusText);
}|
});
|
|
Jack Mack wrote:
But how would I handle the error messages ? I have custom errors for
each of the server errors. Then I have a functionality error handler
if the server code prints out an exception in XML.
On Thu, Feb 12, 2009 at 2:25 PM, Liam Potter <radioactiv...@gmail.com
<mailto:radioactiv...@gmail.com>> wrote:
$.ajax({
type: "GET",
url: "some.php",
data: "name=John&location=Boston",
success: function(msg){
alert( "Success" );
}
});
this isn't a direct translation of your js to jquery but this
shows the principle.
shapo wrote:
Hi Guys
I am having a tough time getting the hang of jQuery so the best of
learning for me is to see my current code in jQuery so I can
understand it better. Here is an GET ajax request I make in JS:
function GET(link) {
// -- Enable Loader Tag
setClassName("message", "display");
// -- Execute xmlhttprequest
var xhr = CreateRequest();
xhr.open("GET",link,false);
xhr.send(null);
try {
// -- Check for Custom Exception Message
var x =
xhr.responseXML.getElementsByTagName("message");
if(x != null) {
//-Print Exception
exception(x[0].childNodes[0].nodeValue);
return false;
}
} catch(e) {
// -- No custom exception found,
continue as normal
if(xhr.status==200) {
setClassName("message", "setnone");
return xhr.responseText;
}
else if(xhr.status==500) {
exception(500);
return false;
}
else if(xhr.status==501) {
exception(501);
return false;
}
else if(xhr.status==404) {
exception(404);
return false;
}
}
}
Is it ok if someone could convert it into a jQuery for me ? I have
gone through many tutorials but I wouldnt know how to implement it
into my code above.