2011-11-17 2 views
0

vb.net에서 JSON 값을 반환하는 데 문제가 있습니다. 참조를 위해 아래 코드를 참조하십시오.vb.net에서 JSON을 사용하는 중에 개체 개체 오류가 발생했습니다.

이것은 내 자바 스크립트 코드입니다. 내가 제출 버튼을 클릭하면

//beging ajax  
$.ajax({  
    type: "POST",  
    url: "../webservices/addpage.asmx/getValue", 
    contentType: "application/json; charset=utf-8", 
    dataType: "json",  
    success: function(msg){ 
     alert(msg); 
    }, 
    error: function(msg){ 
     alert("Error "+ msg); 
    } 
}); 

    //end ajax 

내 JSON 코드 :

<%@ WebService Language="VB" Class="addpage" %> 

Imports System 
imports System.Collections.Generic 
Imports System.Web 
Imports System.Web.Services 
Imports System.Web.Services.Protocols 
Imports System.Web.Script.Services 
Imports System.Web.Script.Serialization 
Imports System.Web.Hosting 
Imports System.Web.HttpContext 
Imports System.IO 

<WebService(Namespace:="http://tempuri.org/")> _ 
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _ 
<ScriptService()> _ 
Public Class addpage 
    Inherits System.Web.Services.WebService 

    <WebMethod()> _ 
    Public Function getValue() As String 
     Return "Invalid" 
    End Function 

End Class 

내 시나리오는 내가 버튼을 누르면 다음은을 getValue 기능이 아니라 반환 값을 경고해야한다는 것입니다 내 항상 [Object Object]의 오류를 경고합니다.

vb.net에서 새로운 기능이므로이 문제를 해결하는 방법에 대한 조언을 구하십시오.

답변

0

에 따르면 $ .ajax 쿼리의 결과는 XMLHttpRequest의 상위 집합 인 jQuery XMLHttpRequest (jqXHR) 객체입니다. 당신의 응답을 주셔서 감사하지만 난 당신의 제안 "경고 (msg.responseText)"를 따라 할 때 지금의 "는 말을

success: function(msg){ 
    alert(msg.responseText); 
}, 
+0

안녕하세요 competent_tech :

는 귀하의 성공 방법을 다시 할 수 있어야한다는 것을 의미 정의되지 않음 ". 이걸 도와주세요. 미리 감사드립니다. – user760260

관련 문제