나는 http://localhost/Test/Test.asmx?op=HelloWorld
에호출 ASMX 웹 서비스 방법은
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace TestWebService
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.Script.Services.ScriptService]
public class Test : System.Web.Services.WebService
{
[WebMethod]
public static string HelloWorld()
{
return "Hello World";
}
}
}
I 버튼을 호출 클릭 IIS 7.5에서 간단한 ASMX 웹 서비스와 웹 애플리케이션을 호스팅 한 그것을 잘 작동하지만 난으로이 메소드를 호출 할 때 ASP.NET 개발 서버 (http://localhost:1756/HTMLPage1.htm
)에서 실행중인 다른 웹 응용 프로그램 프로젝트에서 $ .ajax()를 사용하여 response.status를 0으로 가져오고 웹 메서드를 호출 할 수 없으며 여기에 내 코드가 있습니다.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Consume Test </title>
<script src="jquery-1.5.1.js" type="text/javascript"></script>
<script type="text/javascript">
function displayMessageCall() {
$.ajax({
type: "POST",
url: "http://localhost/Test/Test.asmx/HelloWorld",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: successMsg,
error: errorMsg
});
}
function successMsg(response) {
alert('Success');
}
function errorMsg(response) {
alert(response.status + " " + response.statusText)
}
$(document).ready(function() {
displayMessageCall();
});
</script>
</head>
<body>
</body>
</html>
나는 뭔가가 부족합니까?
easyXDM을 사용하여이 문제를 해결할 수있는 방법을 찾았습니다. http://easyxdm.net/wp/2010/03/17/setting-up-your-first-socket/ – ddfnfal