0

I am using this jQuery to send serialized form data to my controller action:

var data = $('#quiz').serialize();
            //alert(data);

            $.ajax({
                url: '/Challenge/GetQuizScore',
                type: 'post',
                data: { data: data },
                dataType: 'text',
                success: function (result) {
                    // update chart

                },

Then, I am using this controller to read it:

<EmployeeAuthorize()>
<HttpPost()>
Function GetQuizScore(ByVal data As String) As JsonResult

    Debug.Print(data)

    Return Json(data)

End Function

The output of data is like this:

4=True&5=Exercising+regularly

What's the best way to parse this kind of data so I can use it in my action (preferably loop through it something like this:

For Each item in myData

    If (item.value == myArray.value) Then
    ' do something
    Else
    ' do something else
    End If

Next
2
  • 2
    Try to use: jQuery.ajaxSettings.traditional = true; before you code $.ajax(...);. Commented Oct 5, 2012 at 19:00
  • Thanks, but how can I use the data in context of VB.NET. I know how to send but not retrieve. Commented Oct 5, 2012 at 19:13

1 Answer 1

1

You should use json

 $.ajax({
                url: '/Challenge/GetQuizScore',
                type: 'post',
                data: { data: data },
                dataType: 'json',
                success: function (result) {
                    // update chart

                },
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, so how do I use the data in VB.NET?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.