Click here to Skip to main content
15,884,838 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:
XML
<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:

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,
        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:

VB
<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 ?
Posted
Comments
Bh@gyesh 15-Apr-14 5:29am    
Pass data with JSON.strigify method. JSON.strigify(data)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900