How can I do a HTTPget response code on a bogus link on javascript?
I really have no idea what HTTP response codes are and for.
How can I do a HTTPget response code on a bogus link on javascript?
I really have no idea what HTTP response codes are and for.
From Use javascript to check http status codes
$(function() {
var url = "some_url";
$.ajax(url,
{
statusCode: {
404: function() {
alert('page not found');
}
}).done(function( msg ) {
alert( "Data Saved: " + msg );
});
});
See http://en.wikipedia.org/wiki/List_of_HTTP_status_codes For detailed info on what these mean
You can try this way also
$( document ).ready(function() {
var url = "/customers/customer_list";
$.ajax({url:url,
data: { name: "John", location: "Boston" }
type: "GET",
dataType: "html"
success:function(result){
alert(result);
}});
}});