以下のように渡してしまうと、code1 しか渡すことができず、code2 を参照すると null 参照となってしまう。
受け取り側は HttpContext の Request で取得する。
$.ajax({
type: "POST",
url: "http://exsample.com/code.ashx",
data: { "code1": $("#txtCode1").val() },
data: { "code2": $("#txtCode2").val() },
dataType: "json",
cache: true,
success: function (result) {
hoge(result);
},
error: function (obj, err) {
}
});
以下のように Json の変数に整形すると値を渡すことができる。受け取り側は HttpContext の Request で取得する。
var dat = { "code1": $("#txtCode1").val(), "code2": $("#txtCode2").val() };
$.ajax({
type: "POST",
url: "http://exsample.com/code.ashx",
data: dat,
dataType: "json",
cache: true,
success: function (result) {
hoge(result);
},
error: function (obj, err) {
}
});