我在按钮上有一个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);
}
}
});
答案 0 :(得分:4)