执行时我有一些代码,什么都不做。 在chrome调试器上,我看到它显示
无法加载资源:服务器响应状态为500(内部服务器错误)但是字符串很好
abc-wsdlpany/mobile.asmx/ContactGet?searchField=rua&office=97&person=119&user=531&organization=14如果我点击它会显示正确的数据:
< string xmlns = company/ > [{Name: Ruan,Surname:Beneke,Mobile:0831231234,Email:ruan.beneke@company.gov.za}] < / string >我看过我的功能,看起来也是很好,我总是尝试过:successContact,done:successContact。 我的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/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) 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( Mobile)= DirectCast (objSearch( i),company.ETMyProperty.Search).Return6 dr( Email)= DirectCast (objSearch(i),company.ETMyProperty.Search).Return7 dt.Rows.Add(dr) 下一步 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 异常 返回 无 结束 尝试 结束 功能我可以说从我看到的网络服务正在工作,否则我不会看到数据我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/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) 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( Mobile)= DirectCast (objSearch( i),company.ETMyProperty.Search).Return6 dr( Email)= DirectCast (objSearch(i),company.ETMyProperty.Search).Return7 dt.Rows.Add(dr) 下一步 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 异常 返回 无 结束 尝试 结束 功能我可以说从我看到的网络服务正在工作,否则我不会看到数据我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
abc-wsdlpany/mobile.asmx/ContactGet?searchField=rua&office=97&person=119&user=531&organization=14if I click on it it shows the right data:
<string xmlns="company/"> [{"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: "abc-wsdlpany/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 FunctionI 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: "abc-wsdlpany/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 FunctionI 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内部服务器错误
发布评论