خرید بک لینک

Vote count: 0

I have an ASP.NET 2015 community web project. I am trying to use JavaScript to read JSON passed back from the backend. This was coded in VS 2013 and worked. When it failed on my machine, I noticed that the JSON that was being created has double double quotes. I had thought this was a double serialization problem but failed to fix it. Any attempt to simply remove the one of the duplicate double quotes fials. Chr(34) apparently is double double quotes. And """ causes issues as well. There seems to be no way to represent one single set of double quotes.

Here is the backend code...

<System.Web.Services.WebMethod()>
Public Shared Function ConvertDataTabletoString(ByVal laty As String, ByVal longy As String) As String
    Dim mylat As String = laty
    Dim mylong As String = longy

    Dim cmylat As Double
    cmylat = CDbl(Val(mylat))

    Dim cmylong As Double
    cmylong = CDbl(Val(mylong))

    Dim dt As New DataTable()
    Using con As New SqlCoection(my coection here)

    Using cmd As New SqlCommand("working select statement here", con)

            con.Open()

            Dim da As New SqlDataAdapter(cmd)
            da.Fill(dt)
            Dim serializer As New System.Web.Script.Serialization.JavaScriptSerializer()
            Dim rows As New List(Of Dictionary(Of String, Object))()
            Dim row As Dictionary(Of String, Object)
            For Each dr 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

            Retu serializer.Serialize(rows)

        End Using

    End Using

End Function

And here is the front end code I am using to try to parse it....

 function callbackend() {
       $.ajax({
        type: "POST",
        url: "WebForm1.aspx/ConvertDataTabletoString",
        data: JSON.stringify(dataobj),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (data) {
            initializeme(data.d);
           },

        error: function (request, error) {
            alert(request.responseText);
            alert(error);
        }
    });

}
     function initializeme(response) {
        markers = JSON.parse(response);

            });        

    }

asked 40 secs ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 22 خرداد 1395 ساعت: 9:33

صفحه بندی