以下对我有用:
function GetShoppingCartData() {
jQuery.ajax({
type: "POST",
url: "DesktopModules/EcomDnnProducts/AjaxProductDisplay.aspx/GetShoppingCartData",
data: "{'CartId': '" + jQuery(".shoppingcartid").attr("value") + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
cache: false,
success: function (msg) {
//jQuery('#productattributesdata').text(msg.d);
buildShoppingCart(msg.d);
},
fail: function (msg) {
jQuery('#productattributesdata').text(msg.d);
}
});
}
您不需要“数据:....”位
我必须对我的 ASP 页面进行更改才能使其正常工作。我的功能如下所示:
<System.Web.Services.WebMethod()> _
Public Shared Function GetShoppingCartData(ByVal CartId As String) As String
Dim ReturnString As String = ""
Try
ReturnString = "test1;test2;test3"
Catch ex As Exception
'ProcessModuleLoadException(Me, exc)
Dim DataLogger As New DataLogger
DataLogger.WriteToEventLog("Error", ex.Message & " - " & ex.StackTrace)
End Try
Return ReturnString
End Function
看看有没有其他设置...
将以下内容添加到 web.config 以授予要调用的事物的权限:
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>
不确定这是否是缺少的位。
更多资源:
http: //msdn.microsoft.com/en-us/library/byxd99hx (v=vs.80).aspx
http://www.dotnetcurry.com/ShowArticle.aspx?ID=109
http://forums.asp.net/t/1298480.aspx/1
HTH 肖恩