2011-01-06 2 views
1

이 문제를 해결하기 위해 많은 옵션을 사용했지만 작동하지 않습니다.jQuery + ASP.NET 4.0 ajax 페이지 메서드가 작동하지 않습니다.

웹 메서드에서 내 중단 점에 도달하지 않았습니다. 또한 success 함수가 호출되었지만 "hello"문자열이 아닌 전체 페이지 내용이 반환됩니다.

내 페이지에서 asp.net ajax scriptmanager를 전혀 사용하지 않습니다. 일반 jQuery 만 사용합니다. ASP.NET 4.0을 사용하고 있습니다. 간단히

, 내 페이지 메소드가 정의되어 :

[WebMethod] 
public static string Populate() 
{ 
    return "hello"; 
} 

아약스 호출은 다음과 같습니다

$.ajax({ 
    url:'WebForm3.aspx/Populate', 
    data:{}, 
    dataType:"json", 
    type:"GET", 
    success: function(msg) { 
     alert("success"); 
    }, 
    error: function(msg, text) { 
     alert(text); 
    } 
}); 

답변

0

페이지 방법은 작업 할 때 POST 에디션에이 같은 :

$.ajax({ 
    url:'WebForm3.aspx/Populate', 
    data: '{}', 
    dataType:"json", 
    type:"POST", 
    contentType: 'application/json; charset=utf-8', 
    success: function(msg) { 
     alert("success"); }, 
    error: function(msg, text) { 
     alert(text); 
    } 
}); 

데이터 인수를 인용하는 것을 잊지 마십시오 : data: '{}'.

관련 문제