今天刚开始学习jQuery ajax,跟着教程说了什么,但没有奏效。我的jQuery ajax不起作用
HelloWorld
是方法名称,但它似乎不被识别为方法名称,而是基于错误消息被识别为页面名称。
jQuery的
$(document).ready(function() {
//alert("hello world");
$('.ordernumber').on('click', function() {
var orderNum = $(this).text();
$.ajax({
type: "POST",
url: "./OrderDetail.asmx/HelloWorld",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert(msg);
// Do interesting things here.
}
});
//alert($(this).text());
});
});
OrderDetail.asmx.vb
Imports System
Imports System.Web.Services
Public Class OrderDetail
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function HelloWorld() As String
Return "Hello World"
End Function
End Class
错误消息:
POST http://localhost:64616/OrderDetail.asmx/HelloWorld 500 (Internal Server Error)
'内部服务器Error'不是jQuery的故障。 – gdoron
嗨,请尝试在IE中运行它,从那里开发者工具,你将能够知道什么是错误。如果它的内部服务器错误。然后可能会在您正在访问的页面中出现编码错误(OrderDetail)jQuery运行得非常好! –
@AzzaalAhmadZeeshan IE是** NOT **调试ajax – Eonasdan