asp.net - AJAX Callback using POST method -
i require assistance. using jquery cause ajax callback:
function testingcallback(controlid) { if (controlid == 'drpcontrol') { var options = { type: "post", url: "main.aspx", data: { drpcontrol: $(".drpcontrol").val() }, //contenttype: "application/json; charset=utf-8", //cache: false, success: function (data) { }, complete: function (jqxhr, status) { formdata = $("#form1").serialize(); window.location = "main.aspx?" + formdata; showloadingbar(); return false; } }; var resp = $.ajax(options); } }
and backend data so:
request.form["drpcontrol"]
, works well.
but add line callback options : contenttype: "application/json; charset=utf-8",
, value of null request.form["drpcontrol"]
.
please assist on how overcome this.
thanks in advance
might add trying cause postback keep control values, hence line :
formdata = $("#form1").serialize(); window.location = "main.aspx?" + formdata;
but after second postback (on change of drpcontrol) field values gets cleared, assuming has ie not being able cater long querystring, have tested in chrome , works perfect, not ie, , need work ie 8.any suggestions?
in content type add
contenttype: "application/json"
designating encoding redundant json, since default encoding json utf-8. in case receiving server apparently happy knowing it's dealing json , assumes encoding utf-8 default, that's why works or without header.
contenttype (default: 'application/x-www-form-urlencoded; charset=utf-8')- when sending data server, use content type. default "application/x-www-form-urlencoded; charset=utf-8", fine cases. if explicitly pass in content-type $.ajax(), it'll sent server (even if no data sent). if no charset specified, data transmitted server using server's default charset; must decode appropriately on server side.
note sure pass data
data: "{'drpcontrol' : " + $(".drpcontrol").val()+ "}",
Comments
Post a Comment