2014-11-06 4 views
0

나는 ajax를 사용하여 webservice를 호출하려고하는데, 내부 500 ERROR를 얻었습니다. 어떤 일을 잘못하고 있는지, 내가 문제가없는 webmethod를 호출 할 수 있는지 조언 해 주실 수 있습니까? .jquery ajax jsonp와 webservice 호출 : 오류

JQUERY AJAX CALL 

<script type="text/javascript"> 

function LoginVailid() { 

    $.ajax({ 
     url: "http://localhost:49301/AppService.asmx/LoggonAuthentication", 
     contentType: "application/json; charset=utf-8", 
     data: "{}", 
     dataType: "jsonp", 
     jsonp: "callback", 
     crossDomain: true, 
     success: function (json) { 
      alert(json.d); 
     }, 
     error: function() { 
      alert("Hit error fn!"); 
     } 
    }); 
} 
</script> 

WEBSERVICE 방법

[WebService(Namespace = "http://tempuri.org/")] 
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 
[System.ComponentModel.ToolboxItem(false)] 

[System.Web.Script.Services.ScriptService] 
public class Service1 : System.Web.Services.WebService 
{ 

    [WebMethod] 
    [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)] 
    public string LoggonAuthentication() 
    { 
     return "Hello World"; 
    } 

} 
+0

당신은 JSON'에 jsonp''에서 변화'dataType'를 시도 할 수 ' –

+0

내가 그렇게하면 다음 ERROR.XMLHttpRequest를 얻을 수 없습니다. 광고 http : // localhost : 49301/AppService.asmx/LoggonAuthentication? {}. 'Access-Control-Allow-Origin'헤더가 요청 된 리소스에 없습니다. 따라서 'http : // localhost : 55255'는 액세스가 허용되지 않습니다. 응답에 HTTP 상태 코드 500이 있습니다. –

+0

> 아약스를 사용하여 webservice를 호출하려고합니다. 내부 500 오류가 발생했습니다. 실제 예외를 디버그하고 확인할 수 있습니까? –

답변

0

것은이 articlethis SO question 데 도움이 코드 또한

[WebMethod] 
[ScriptMethod(UseHttpGet = true, XmlSerializeString=false, ResponseFormat = ResponseFormat.Json)] 
public string LoggonAuthentication(string callback) 
{ 
    return callback + "({message: 'Hello World'})"; 
} 

을 시도