jsonp语法错误意外令牌

时间:2013-04-11 05:02:45

标签: jsonp

如果我使用dataType:json我在回复中没有收到错误/

如果我使用dataType:jsonp,我会收到以下错误:

  

语法错误意外令牌

这是我的jquery代码

function testJsonp()
{
            $.ajax({
                            type: "POST",
                            url: "http://localhost/FT8Services/FTService.asmx/testjsonp",                                
                            data: "{firstname: '" + encodeURIComponent("Stack") + "', lastname: '" + encodeURIComponent("Overflow") + "'}",
                            contentType: "application/json; charset=utf-8",
                            dataType: "jsonp",                               
                            success: function (result) {                   
                                var loginfo = eval(result.d);
                                alert(loginfo[0]);
                                if(loginfo.length > 1)
                                {
                                    alert("Sucess");    
                                }
                                else
                                {
                                    alert("no access");
                                }
                            },
                            error: function(xhr, status, error) {
                                alert(error);
                            }       
                        })
}

这是我的asp.net网络方法

 <WebMethod()> _
Public Function testjsonp(ByVal firstname As String, ByVal lastname As String) As String
    Dim rdatas As New List(Of String)
    Dim fullname As String = firstname & lastname
    For i As Integer = 1 To 5
        rdatas.Add(fullname & " " & i.ToString)
    Next
    Dim js As New JavaScriptSerializer
    Dim strJSON As String = js.Serialize(rdatas.ToArray)

    Return strJSON
End Function

0 个答案:

没有答案