i am trying to make an ajax request it is not working properly
my code
function checkUserName() {
debugger
var userName = 'vipin jain';
$.ajax({
type: "POST",
url: "Default.aspx/isUserAvailable",
data: { userName: "+userName+" },
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert(msg.d);
$(".successNotification").removeAttr('display');
},
error: function (xhr, err) {
alert("readyState: " + xhr.readyState + "\nstatus: " + xhr.status);
alert("responseText: " + xhr.responseText);
}
});
}
can u tell me what is going wrong.
You really should notice what is going wrong, what error message you are receiving, what doesn’t work as expected. From this I can see 2 possible things going wrong:
The
debuggerline, what is that about? Remove it and debug with Firebug in Firefoxdata: { userName: "+userName+" },This always gives ‘+userName+’ as the username, I guess you need the username here? Do it like this:{ userName: userName }.