javascript - Json stringify double quotes -


i can't seem around issue... json i'm trying pass mvc controller keeps coming out this

"\"{materialquantity: { materialid :18, quantity:1}}\"" 

this code generates it:

function createjsonforquantities() {     var inputs = $('input[name=materialquantity]');     var total = inputs.length;     var data = "";      inputs.each(function (index) {         data = data + $(this).val();         if (index != total -1)             data = data + ',';     });      return data;         } 

and hidden reads data (of course auto-generated well)

<input name="materialquantity" type="hidden" value="{materialquantity: { materialid :12, quantity:5}}" /> 

what doing wrong?

update

ok i'm getting json object , ajax requests looks this. problem pass proper objects values null in controller action :(

var form_data = createjsonfornorm(); var quantity_data = createjsonforquantities(); var data = { norm: form_data, mqvm: quantity_data }; $.ajax({    type: "post",    url: form.attr("action"),    data: data,    success: function () {        location.href = "@url.action("index")";        ('#adddialog').dialog("close");    },    error: function () {        alert("error");    } }); 

try using json.stringify(data) in request


Comments