使用 jQuery.ajax(如下所示)调用 webmethod 代码在 IIS 服务器中不起作用。在本地开发环境(cassini Web 服务器)中也是如此。
返回的消息是“找不到对象”。
此外,尝试使用浏览器访问 Web 方法:
" http://Test.com/TestWeb/Test.aspx/GetSize " "系统找不到指定的文件。"
------------------------------------------------
Code:
------------------------------------------------
function getfileProp() {
var x = false;
debugger;
var pagePath = window.location.href;
debugger;
window.jQuery.ajax({
url: pagePath + '/GetSize',
data: "{'fileNameWithPath': '" + f + "'}",
dataType: "json",
type: "POST",
async: false,
contentType: 'application/json; charset=utf-8',
complete: function(jsondata, stat) {
},
error: function(request, status, error) {
alert(status);
}
});
return x;
}