Reputation: 881
I'm stuck with following problem.
A page requests user and password. If an user and his password exists, the page outputs just a plain 1. Otherwise a 0.
How do I check this with jquery ajax and process it further depending on the output?
$(function () {
$("#checkCode").click(function () {
var var_pCode = $("#ctl00_ContentPlaceHolder1_tbPartner").val();
var var_cCode = $("#ctl00_ContentPlaceHolder1_tbCode").val();
var myResult
$.ajax({
url: "codeValidator.aspx",
dataType: "text",
data: { pCode: var_pCode, cCode: var_cCode }
}).done(function (msg) {
//alert(msg);
if (msg = "1") { alert('111'); }
else {alert('000')}
});
});
});
thanks in advance
Upvotes: 0
Views: 3474
Reputation: 148110
In asp.net we have to do msg.d try this. Secondly you are missing the webmethod name in url. The is a nice example you calling server side method by jquery ajax with asp.net
$.ajax({
url: "codeValidator.aspx/SomeStaticWebMethodOfServerSide",
dataType: "text",
data: { pCode: var_pCode, cCode: var_cCode }
}).done(function (msg) {
//alert(msg);
if (msg.d == "1") { alert('111'); }
else {alert('000')}
});
Upvotes: 1
Reputation: 2122
You're doing an assignment in your if statement.
It should be
if ("1" == msg) { }
Upvotes: 0