0
你能告诉我在哪里的问题是这样的代码:与JqueryMobile调用Web服务将无法正常工作
$('#callAjax').live('click', function (event) {
// $("#resultLog").html("Working....");
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Hello.asmx/HelloWorld",
data: "{}",
dataType: "json",
success: function (msg) {
alert(msg);
//$("#resultLog").html(msg);
}
}); // end of ajax
$("#resultLog").ajaxError(function (event, request, settings, exception) {
$("#resultLog").html("Error Calling: " + settings.url + "<br />HTPP Code: " + request.status);
});
}); // end of click
在HTML文件
<input id="callAjax" type="button" value="Call Ajax" />
<div id="resultLog"></div>
这里是一些代码是我的web服务:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Serialization;
/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService {
public WebService() {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public static string HelloWorld() {
return "Hello World";
}
}
返回值为:Error Calling: Hello.asmx/HelloWorld HTPP Code: 500
。
ASMX文件与我在其中调用Web服务的自定义JavaScript文件位于同一文件夹中。 我尝试了很多,但没有找到解决方案的运气。非常感谢您的帮助!
的问题是在该行网址:“Hello.asmx/HelloWorld”的,...路径错了...我纠正它,现在它的工作原理.. 。! – bp581 2011-02-09 18:20:07