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
jQuery.ajaxSettings.traditional = true;before you code$.ajax(...);.