我在按钮上有一个 jquery 单击它在后端代码中运行一个函数。我的代码将返回一个可能包含一些值的字符串。我可以说如果我的字符串包含然后意味着成功否则显示错误(请参阅下面的代码),以下代码会引发语法错误:
$.ajax({
type: "POST",
url: "MyPage.aspx/MyFunction",
data: "{'totalToPay': '" + totalToPay + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
if (msg.d.contains('https://')) { // THIS IS WHERE IT THROWS ERROR. AM DOING THIS AS MY STRING MAY CONTAIN http://www.test.com
alert("TEST");
}
else {
$("#error").show();
msgbox.html(msg.d);
}
}
});