I know there is some posts on this but they did not help me. My program run's and when I click on a button to fire a javascript nothing happens, or no response. In chrome debugger under network tab I see in red
http://wms-wsdl.company.net/mobile.asmx/ContactGet?searchField=test&office=97&person=119&user=531&organization=14
when I click on that link it shows a red circle with 500 internal server error. If I click on the response I see:
{"Message":"Invalid JSON primitive: test.","StackTrace":" at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializePrimitiveObject()\r\n at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth)\r\n at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer)\r\n at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)\r\n at System.Web.Script.Services.RestHandler.GetRawParamsFromGetRequest(HttpContext context, JavaScriptSerializer serializer, WebServiceMethodData methodData)\r\n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.ArgumentException"}
Now I have no Idea what that means.
When I double click in that lick It shows me all my data that is supposed to be inserted into a list view (data is xml) e.g. <string xmlns="http://company.net/">
[ { "Name": "Myar", "Surname": "Tester", "Mobile": "080000000", "Email": "" ......}, etc
My javascript function is as follows:
function initContactView()
{
alert("ContactView start test")
var txtSearch = $("#searchTextField").val();
$.ajax({
type: "GET",
dataType:"json",
contentType: "application/json; charset=utf-8",
crossDomain: true,
url: "http://dsf-wsdl.company.net/mobile.asmx/ContactGet",
data: "searchField="+txtSearch+"&office="+localStorage.getItem("office")+"&person="+localStorage.getItem("person")+"&user="+localStorage.getItem("user")+"&organization="+localStorage.getItem("organization"),
success:successContact,
failure: function (msg) {
console.log(msg);
alert(msg)
}
});
alert("ContactView End Test");
}
function successContact(data) {
alert("Success Start Test");
window.location = "#contactsview";
$("#lstView_contacts").kendoMobileListView({
dataSource: JSON.parse(data.d),
template: $("#lstView_contact_Template").html(),
endlessScroll: true,
scrollThreshold: 8
});
alert("Success Start Test");
}
searchTextField
comes from my HTML textbox.
What I seem to find odd is that it gets the data it should, I have verified that in the xml but still gives an error. My webservice that I am using is a json webservice. It alerts both alerts but I think it goes into failure.
The response i get in debugger is:
<string xmlns="http://company.net/">[
{
"Name": "Myar",
"Surname": "Tester",
"Mobile": "080000000",
"Email": "test@test.com"
}]</string
How my webservice looks:
<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 have been on this for a few days now and I cant seem to get any solution. Any help?