2014-11-19 2 views
0

일반 HTML 페이지에서 asmx 웹 서비스를 호출하려고합니다. 그러나 출력이 나오지 않습니다. 정확한 문제가 발생하지 않습니다. 다음은 asmx 웹 서비스라고 부르는 내 아약스 코드입니다.일반 HTML 페이지를 사용하여 .asmx 웹 서비스를 호출하는 방법

function Getdet(Name) 
     { 
      alert('hellotest'); 
      $.ajax({ 
       type: "POST", 
       url: "http://192.168.1.20/myservice/service.asmx?HelloWorld", // add web service Name and web service Method Name 
       data: "{''}", //web Service method Parameter Name and ,user Input value which in Name Variable. 
       contentType: "application/json; charset=utf-8", 
       dataType: "json", 
       success: function (response) 
       { 
        alert('abcd1'); 
        $("#spnGetdet").html(response.d); //getting the Response from JSON 
       }, 
       failure: function (msg) 
       { 
        alert(msg); 
       } 
     }); 
    } 

코드에 아무 것도 추가해야합니까? ?? 위의 코드에서 어디서 잘못 될지 알려주세요.

+0

개최 장소 :이 모든 작업이 끝나면

, 당신은 다음과 같은 전화를 사용할 것인가? html로 동일한 도메인에 있습니까? – Chris

답변

0

ASMX 페이지는 보통 구식 웹 서비스이고 출력은 항상 XML 형식입니다. 따라서 JSON을 제외하고는 사용하지 마십시오.

또한 기본적으로 다른 도메인 호출에서 제대로 작동하지 않으므로 cross domain이 올바르게 처리되었는지 확인해야합니다. WebService에이

success: function(response) { 
    // http://stackoverflow.com/a/1773571/28004 
    var xml = parseXml(response), 
     json = xml2json(xml); 

    $("#spnGetdet").html(json.d); 

}