ASCX.CS클라이언트 측에서 JSON 문자열을 렌더링 할 수없는
protected string BindData()
{
List<Product> products = product.GetRepeaterData(prod);
string json = JsonConvert.SerializeObject(products);
return json;
}
ASCX는
<script type="text/javascript" language="javascript">
function doSomething() {
$.ajax({
type: "POST",
url: "/ProgramListSimple.aspx/BindData",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert(msg);
}
});
};
나는 잘 모릅니다 어떤 경고 .. 난을 볼 수 아니다 이 코드는 사용자 컨트롤에 대한 것입니다 & aspx 페이지에 그게 중요합니까? 디버깅하는 동안 직렬화 된 데이터를 json 문자열로 볼 수 있습니다. 클라이언트 측에서 렌더링하지 않는다는 것입니다 .... 아침부터 지금 작업하고 있습니다. 도움이 필요합니다. 어떤 예나 다른 문서도 유용 할 수 있습니다.
'alert()'대신'console.log()'를 사용하면 디버거 콘솔에서 전체 JSON 객체를 볼 수 있습니다. 'alert()'는 문자열만을 보여줄 수 있습니다. – Blazemonger
@Blazemonger가 작동하지 않습니다. 콘솔에서도 볼 수 없습니다. – Scorpio
빈 파일이'/ ProgramListSimple.aspx/BindData'에 의해 반환되고 있음을 나타냅니다. success : function (msg) { console.log (msg); }'이 (가) 스크립트가 정상적으로 표시 되더라도 무엇이든지 표시해야합니다. – Blazemonger