JavaScript 500内部服务器错误 [英] JavaScript 500 internal server error

查看:168
本文介绍了JavaScript 500内部服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

执行时我有一些代码,什么都不做。

在chrome调试器上,我看到它显示

无法加载资源:服务器响应状态为500(内部服务器错误)

但是字符串很好

 http://abc-wsdl.company.net/mobile.asmx/ContactGet?searchField=rua&office=97&person=119&user=531&organization=14 

如果我点击它会显示正确的数据:

 <   string     xmlns   =  http://company.net/ >  
[{Name: Ruan,Surname:Beneke,Mobile:0831231234,Email:ruan.beneke@company.gov.za}]
< / string >





我看过我的功能,看起来也是很好,我总是尝试过:successContact,done:successContact。



我的javascript函数:



< pre lang =Javascript> function ContactView()
{
alert( 1
var txtSearchbox = $( #searchTextField)。val();
$ .ajax({
type: GET
data:param = searchField = + txtSearchbox + & office = + localStorage.getItem( office)+ & person = + localStorage.getItem( person)+ & user = + localStorage.getItem( user)+ & organization = + localStorage.getItem( organization),
contentType: application / json; charset = utf-8
url: http:// abc-wsdl。 company.net/mobile.asmx/ContactGet
dataType: json
crossDomain: true
成功:successContact,
错误: function (msg){
console .log(msg)
}
});
alert( 2
}





它不会调用successContact只会出错。或者不是错误它什么都不做,然后chrome调试器显示上面提到的消息。



我的网络服务代码:



< WebMethod()> _ 
< ScriptMethod(ResponseFormat:= ResponseFormat .Json,UseHttpGet:= True)> _
公共 功能 ContactGet( ByVal searchField 作为 字符串 ByVal office 作为 字符串 ByVal person 正如 字符串 ByVal user As 字符串 ByVal 组织作为 字符串作为 字符串

Dim objSearch 作为 ArrayList
Dim objSearching As 搜索
Dim intResult As 整数

尝试
' 测试字符串
intResult = objSearching.SearchByKeyword(searchField,person,office,organization,user,company.ETMyProperty.Search.enmSearchType.enmContact,objSearch)

Dim objContact 作为
Dim dt 作为 DataTable( 联系人

D im col_Name 作为 DataColumn( 名称 GetType String ))
dt.Columns.Add(col_Name)

Dim col_Mobile As DataColumn( 姓氏 GetType String ))
dt.Columns.Add(col_Mobile)

Dim col_Office 作为 DataColumn( Mobile GetType String ))
dt.Columns.Add(col_Office)

Dim col_Category As DataColumn( Email GetType String ))
dt.Columns.Add(col_Category)

< span class =code-keyword> Dim dr As DataRow

For i = 0 objSearch.Count - 1
dr = dt.NewRow()
dr( 名称)= DirectCast (objSearch(i),company.ETMyProperty.Search).Return2
dr( )= DirectCast (objSearch(i),company.ETMyProperty.Search).Return3
dr(< span class =code-string> Mobile)= DirectCast (objSearch( i),company.ETMyProperty.Search).Return6
dr( Email)= DirectCast (objSearch(i),company.ETMyProperty.Search).Return7

dt.Rows.Add(dr)
< span class =code-keyword>下一步

Dim 序列化器 As JavaScriptSerializer()
Dim 作为 列表( 字典( Of 字符串对象))()
Dim 作为字典( 字符串对象)=

' 序列化dt行到json输出
对于 每个 drow As DataRow In dt.Rows
row = 字典( String Object )()
对于 每个 col As DataColumn In dt.Columns
row.Add(col.ColumnName,dr(col))
下一步
rows.Add(row)
下一步

Dim str_json = JsonConvert.SerializeObject(dt,Formatting.Indented)

返回 str_json

Catch ex As 异常
返回
结束 < span class =code-keyword>尝试

结束 功能





我可以说从我看到的网络服务正在工作,否则我不会看到数据我f我在调试器中单击链接。它也使得查询字符串正确。



我已经在这两天了,我不知道问题是什么。有什么想法吗?

解决方案

#searchTextField)。val();


.ajax({
type: GET
data:param = searchField = + txtSearchbox + & office = + localStorage.getItem( office)+ & person = + localStorage.getItem( person)+ & user = + localStorage.getItem( user)+ &am p; organization = + localStorage.getItem( organization),
contentType: application / json; charset = utf-8
url: http:// abc-wsdl。 company.net/mobile.asmx/ContactGet
dataType: json
crossDomain: true
成功:successContact,
错误: function (msg){
console .log(msg)
}
});
alert( 2
}





它不会调用successContact只会出错。或者不是错误它什么都不做,然后chrome调试器显示上面提到的消息。



我的网络服务代码:



< WebMethod()> _ 
< ScriptMethod(ResponseFormat:= ResponseFormat .Json,UseHttpGet:= True)> _
公共 功能 ContactGet( ByVal searchField 作为 字符串 ByVal office 作为 字符串 ByVal person 正如 字符串 ByVal user As 字符串 ByVal 组织作为 字符串作为 字符串

Dim objSearch 作为 ArrayList
Dim objSearching As 搜索
Dim intResult As 整数

尝试
' 测试字符串
intResult = objSearching.SearchByKeyword(searchField,person,office,organization,user,company.ETMyProperty.Search.enmSearchType.enmContact,objSearch)

Dim objContact 作为
Dim dt 作为 DataTable( 联系人

D im col_Name 作为 DataColumn( 名称 GetType String ))
dt.Columns.Add(col_Name)

Dim col_Mobile As DataColumn( 姓氏 GetType String ))
dt.Columns.Add(col_Mobile)

Dim col_Office 作为 DataColumn( Mobile GetType String ))
dt.Columns.Add(col_Office)

Dim col_Category As DataColumn( Email GetType String ))
dt.Columns.Add(col_Category)

< span class =code-keyword> Dim dr As DataRow

For i = 0 objSearch.Count - 1
dr = dt.NewRow()
dr( 名称)= DirectCast (objSearch(i),company.ETMyProperty.Search).Return2
dr( )= DirectCast (objSearch(i),company.ETMyProperty.Search).Return3
dr(< span class =code-string> Mobile)= DirectCast (objSearch( i),company.ETMyProperty.Search).Return6
dr( Email)= DirectCast (objSearch(i),company.ETMyProperty.Search).Return7

dt.Rows.Add(dr)
< span class =code-keyword>下一步

Dim 序列化器 As JavaScriptSerializer()
Dim 作为 列表( 字典( Of 字符串对象))()
Dim 作为字典( 字符串对象)=

' 序列化dt行到json输出
对于 每个 drow As DataRow In dt.Rows
row = 字典( String Object )()
对于 每个 col As DataColumn In dt.Columns
row.Add(col.ColumnName,dr(col))
下一步
rows.Add(row)
下一步

Dim str_json = JsonConvert.SerializeObject(dt,Formatting.Indented)

返回 str_json

Catch ex As 异常
返回
结束 < span class =code-keyword>尝试

结束 功能





我可以说从我看到的网络服务正在工作,否则我不会看到数据我f我在调试器中单击链接。它也使得查询字符串正确。



我已经在这两天了,我不知道问题是什么。有什么想法?


I have some code when executed it does nothing.
On chrome debugger I see that it shows

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

but the string is fine

http://abc-wsdl.company.net/mobile.asmx/ContactGet?searchField=rua&office=97&person=119&user=531&organization=14

if I click on it it shows the right data:

<string xmlns="http://company.net/">
[{"Name":"Ruan","Surname":"Beneke","Mobile":"0831231234","Email":"ruan.beneke@company.gov.za"}]
</string>



I have looked at my function and it also look's fine, I have tried always : successContact, done : successContact.

My javascript function:

function ContactView()
{
    alert("1")
    var txtSearchbox = $("#searchTextField").val();
$.ajax({
        type: "GET",
        data: param = "searchField="+txtSearchbox+"&office="+localStorage.getItem("office")+"&person="+localStorage.getItem("person")+"&user="+localStorage.getItem("user")+"&organization="+localStorage.getItem("organization"),
        contentType: "application/json; charset=utf-8",
        url: "http://abc-wsdl.company.net/mobile.asmx/ContactGet",
        dataType: "json",
        crossDomain: true,
        success: successContact,
        error: function (msg) {
            console.log(msg)
        }
    });
    alert("2")
}



It does not call successContact only goes into error. Or not error it does nothing and then chrome debugger shows the message mentioned above.

My webservice code:

<WebMethod()> _
    <ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=True)> _
    Public Function ContactGet(ByVal searchField As String, ByVal office As String, ByVal person As String, ByVal user As String, ByVal organization As String) As String

        Dim objSearch As New ArrayList
        Dim objSearching As New Search
        Dim intResult As Integer

        Try
            'Test String
            intResult = objSearching.SearchByKeyword(searchField, person, office, organization, user, company.ETMyProperty.Search.enmSearchType.enmContact, objSearch)

            Dim objContact As New Person
            Dim dt As New DataTable("Contacts")

            Dim col_Name As New DataColumn("Name", GetType(String))
            dt.Columns.Add(col_Name)

            Dim col_Mobile As New DataColumn("Surname", GetType(String))
            dt.Columns.Add(col_Mobile)

            Dim col_Office As New DataColumn("Mobile", GetType(String))
            dt.Columns.Add(col_Office)

            Dim col_Category As New DataColumn("Email", GetType(String))
            dt.Columns.Add(col_Category)

            Dim dr As DataRow

            For i = 0 To objSearch.Count - 1
                dr = dt.NewRow()
                dr("Name") = DirectCast(objSearch(i), company.ETMyProperty.Search).Return2
                dr("Surname") = DirectCast(objSearch(i), company.ETMyProperty.Search).Return3
                dr("Mobile") = DirectCast(objSearch(i), company.ETMyProperty.Search).Return6
                dr("Email") = DirectCast(objSearch(i), company.ETMyProperty.Search).Return7

                dt.Rows.Add(dr)
            Next

            Dim serializer As New JavaScriptSerializer()
            Dim rows As New List(Of Dictionary(Of String, Object))()
            Dim row As Dictionary(Of String, Object) = Nothing

            'serialize dt row to json output
            For Each drow As DataRow In dt.Rows
                row = New Dictionary(Of String, Object)()
                For Each col As DataColumn In dt.Columns
                    row.Add(col.ColumnName, dr(col))
                Next
                rows.Add(row)
            Next

            Dim str_json = JsonConvert.SerializeObject(dt, Formatting.Indented)

            Return str_json

        Catch ex As Exception
            Return Nothing
        End Try
    End Function



I can say from what I saw that the webservice is working otherwise I wont see the data if I click in the link in debugger. also It gets the query string right.

I have been on this for two day's and I cant say what the problem is. Any ideas ?

解决方案

("#searchTextField").val();


.ajax({ type: "GET", data: param = "searchField="+txtSearchbox+"&office="+localStorage.getItem("office")+"&person="+localStorage.getItem("person")+"&user="+localStorage.getItem("user")+"&organization="+localStorage.getItem("organization"), contentType: "application/json; charset=utf-8", url: "http://abc-wsdl.company.net/mobile.asmx/ContactGet", dataType: "json", crossDomain: true, success: successContact, error: function (msg) { console.log(msg) } }); alert("2") }



It does not call successContact only goes into error. Or not error it does nothing and then chrome debugger shows the message mentioned above.

My webservice code:

<WebMethod()> _
    <ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=True)> _
    Public Function ContactGet(ByVal searchField As String, ByVal office As String, ByVal person As String, ByVal user As String, ByVal organization As String) As String

        Dim objSearch As New ArrayList
        Dim objSearching As New Search
        Dim intResult As Integer

        Try
            'Test String
            intResult = objSearching.SearchByKeyword(searchField, person, office, organization, user, company.ETMyProperty.Search.enmSearchType.enmContact, objSearch)

            Dim objContact As New Person
            Dim dt As New DataTable("Contacts")

            Dim col_Name As New DataColumn("Name", GetType(String))
            dt.Columns.Add(col_Name)

            Dim col_Mobile As New DataColumn("Surname", GetType(String))
            dt.Columns.Add(col_Mobile)

            Dim col_Office As New DataColumn("Mobile", GetType(String))
            dt.Columns.Add(col_Office)

            Dim col_Category As New DataColumn("Email", GetType(String))
            dt.Columns.Add(col_Category)

            Dim dr As DataRow

            For i = 0 To objSearch.Count - 1
                dr = dt.NewRow()
                dr("Name") = DirectCast(objSearch(i), company.ETMyProperty.Search).Return2
                dr("Surname") = DirectCast(objSearch(i), company.ETMyProperty.Search).Return3
                dr("Mobile") = DirectCast(objSearch(i), company.ETMyProperty.Search).Return6
                dr("Email") = DirectCast(objSearch(i), company.ETMyProperty.Search).Return7

                dt.Rows.Add(dr)
            Next

            Dim serializer As New JavaScriptSerializer()
            Dim rows As New List(Of Dictionary(Of String, Object))()
            Dim row As Dictionary(Of String, Object) = Nothing

            'serialize dt row to json output
            For Each drow As DataRow In dt.Rows
                row = New Dictionary(Of String, Object)()
                For Each col As DataColumn In dt.Columns
                    row.Add(col.ColumnName, dr(col))
                Next
                rows.Add(row)
            Next

            Dim str_json = JsonConvert.SerializeObject(dt, Formatting.Indented)

            Return str_json

        Catch ex As Exception
            Return Nothing
        End Try
    End Function



I can say from what I saw that the webservice is working otherwise I wont see the data if I click in the link in debugger. also It gets the query string right.

I have been on this for two day's and I cant say what the problem is. Any ideas ?


这篇关于JavaScript 500内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆