【发布时间】:2017-06-01 03:56:30
【问题描述】:
我在我的项目中使用 asp.net 路由和 asp.net webforms 但我的 jquery ajax 方法不起作用 我如何解决这个问题
我的服务器端方法是:
[WebMethod]
public static string search(List<string> aData)
{
//my code
return "resault";
}
我的客户端功能是:
function search(e) {
if (e.value == "") {
//$("#imgLoading").hide();
$("#search-res").html("");
$("#search-res").slideUp();
return;
}
else {
$("#search-res").html("<img src='/content/img/loading (4).gif' alt='Alternate Text' />");
}
var aData = [];
aData[0] = e.value;
var jsonData = JSON.stringify({ aData: aData });
$.ajax({
type: "POST",
url: '/User/default.aspx/search',
data: jsonData,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (res) {
var items = res.d;
$("#search-res").html(res.d);
$("#search-res").slideDown();
},
error: function (type) {
alert(type.responseText);
}
});
}
在我使用路由之前,我的 jquery 函数工作正常
【问题讨论】:
-
alert which is inside error.,这叫什么??您是否收到任何失败通知?
-
HTTP 错误 404.0 - 未找到您要查找的资源已被删除、更改名称或暂时不可用。
-
是的,我收到 http 错误 404
-
你能发布你的 .aspx 代码吗?
-
否,因为它找不到我要发布的网址
标签: jquery asp.net ajax webforms routing