title: 500 internal server error ajax/javascript
body: <p>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 </p>
  
  <p><code>http://wms-wsdl.company.net/mobile.asmx/ContactGet?searchField=test&amp;office=97&amp;person=119&amp;user=531&amp;organization=14</code></p>
  
  <p>when I click on that link it shows a red circle with 500 internal server error.
  If I click on the response I see:</p>
  
  <p><code>{"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"}</code> </p>
  
  <p>Now I have no Idea what that means. </p>
  
  <p>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. <code>&lt;string xmlns="http://company.net/"&gt;
  [ { "Name": "Myar", "Surname": "Tester", "Mobile": "080000000", "Email": "" ......}, etc</code></p>
  
  <p>My javascript function is as follows:</p>
  
  <pre><code>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+"&amp;office="+localStorage.getItem("office")+"&amp;person="+localStorage.getItem("person")+"&amp;user="+localStorage.getItem("user")+"&amp;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");    
  }
  </code></pre>
  
  <p><code>searchTextField</code> comes from my HTML textbox.</p>
  
  <p>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.</p>
  
  <p>The response i get in debugger is:</p>
  
  <pre><code>&lt;string xmlns="http://company.net/"&gt;[
    {
      "Name": "Myar",
      "Surname": "Tester",
      "Mobile": "080000000",
      "Email": "test@test.com"
    }]&lt;/string
  </code></pre>
  
  <p>How my webservice looks:</p>
  
  <pre><code>&lt;WebMethod()&gt; _
      &lt;ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=True)&gt; _
      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
  </code></pre>
  
  <p>I have been on this for a few days now and I cant seem to get any solution.
  Any help?</p>