asp.net - Deserialise json form string -
i have dynamic build form, buildt textfile don't know names of variables in advance. have serialized form , values json string:
"personid=aasd&gender=kvinna&education=sd&relativedementia=ja&apoe4=vet+ej& systolicbt=asd&hypertoniatreatment=nej&fpcolesterol=asd&personlength=asdas &personweight=dasd&personbmi=asd&abdominalcircumference=adsasd &knowndiabetesmellitus=ja&hadtiastroke=ja &knownheartdisease=ja &iscurrentlysmoking=ja&isexperiencingstress=nej &knowndepression=ja%2c+tidigare+behandlad&physicallyactive=ja"
with method:
$(document).on("click", "#btnsubmit", function() { $.ajax({ url: "/home/riskscore", type: "post", data: { "testdata": $("form").serialize() }, success: function(result) { }
and want deserialize can show values , name each value on next page. have tried lot of different variations of code have not succeded. hope can help!
thanks
you haven't got json data, it's standard url encoded notation. if want access on server side can loop on post data. asp.net automatically parses format request.form
collection.
foreach(string key in request.form.allkeys) response.write(request.form[key]);
you need change ajax to:
data: $("form").serialize(),
the reason because don't want testdata
identifier, want raw post data data
property.
Comments
Post a Comment