我一直在尝试后2 parameteres ... 这是阿贾克斯code
I have been trying to post two parameteres... This is the ajax code
function Kaydet() {
var params = {};
var Kiralayan = $("#RentForm").serialize();
params.kisi = Kiralayan ;
params.aracid = P.AracID;
console.log(params);
$.ajax({
type: "POST",
url: '@Url.Action("Save","AracKirala")',
data: params,
dataType: "text",
success: function (response) {
if (response != "OK") {
alert("Kayıt yapılamadı.");
}
else {
document.getElementById("RentForm").reset();
alert("Kayıt başarıyla gerçekleştirildi.");
$("#myModal").modal('hide');
Ara();
}
}
});
方法
public ActionResult Save(Kiralayan kisi = null, int aracid = 0)
{
问题是AJAX帖aracidcorretly但kisi变成空当方法触发时... 我试着不张贴aracid与kisi,让阿贾克斯贴好一个参数kisi,但不工作在一起...
the problem is ajax posts "aracid" corretly but "kisi" turns null when the method is trigged... I tried not to post "aracid" with "kisi" so ajax posted well for one parameter "kisi", but doesnt work together...
如果您序列化的形式,那么你可以添加额外的值,它与 .PARAM()
功能
If you serializing the form, then you can add additional values to it with the .param()
function
var data = $("#RentForm").serialize() + '&' + $.param({ 'aracid': AracID }, true);
$.ajax({
type: "POST",
url: '@Url.Action("Save","AracKirala")',
data: data,
....
上一篇:如何触发功能时,所有的Ajax完成?有的、功能、Ajax
下一篇:jQuery的阿贾克斯返回" parsererror"尽管JSON是有效的,收益code是201收益、有效、QUOT、阿贾克斯