Specify only the second parameter in a javascript function
Posted
by Ben McCormack
on Stack Overflow
See other posts from Stack Overflow
or by Ben McCormack
Published on 2010-05-12T20:23:30Z
Indexed on
2010/05/12
20:34 UTC
Read the original article
Hit count: 246
JavaScript
The spec for the jQuery ajax.error
function is:
error(XMLHttpRequest, textStatus, errorThrown)Function
I'm trying to catch the error and display the textStatus
, but I can't figure out how to specify only the textStatus
without having to put in a variable name for XMLHttpRequest
and errorThrown
. My code currently looks like this:
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: hbAddressValidation.webServiceUrl,
data: this.jsonRequest,
dataType: "json",
timeout: 5,
success: function (msgd) {
//...
},
error: function (a,textStatus,b) {
$("#txtAjaxError").val("There was an error in the AJAX call: "
+ textStatus);
}
});
You can see in my code that I'm putting variables a
and b
as placeholders for the first and last variables in the error
function. I know that in my success function, I'm only providing one parameter and it works fine, but in that case data
is the first parameter. In the case of error
, textStatus
is the second parameter, but that's the only one I want to specify. Is this possible?
© Stack Overflow or respective owner