私は1つのポートlocalhost:5739でasmxサービスを実行しており、他のポートまたはプレーンhtml +プロジェクトからjqueryからサービスを呼び出そうとしています
しかし、私はWebサービスにアクセスできません
私のウェブサービスは
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string HelloWorld(string text) {
return "Hello World" + text;
}
そして、Webサービスを呼び出す私のコードは
$.ajax(
{
type: "POST",
url: "http://localhost:5739/asmxservices/testservice.asmx/HelloWorld",
data: '{ "text": "Kartheek"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
error: OnError
});
function OnSuccess(data, status) {
alert(data.d);
};
function OnError(msg) {
alert('error = ' + msg.d);
}