请在这件事上给予我帮助...
我必须将值传递给 php 文件进行保存,但是如果选中了一个复选框,它必须使用第一个返回值执行第二个 jquery 帖子。但似乎第二个 jquery 帖子首先被执行,这是我的代码:
if($action=="save_prod")
{
var remember = document.getElementById('chk');
var $suppid=document.getElementById('supp').value;
var $categlist=document.getElementById('categlist').value;
var $prodname=document.getElementById('prodname').value;
var $proddesc=document.getElementById('proddesc').value;
$.post(baseurl+'index.php/main/newproduct',{"categlist" : $categlist,"prodname" : $prodname," proddesc" : $proddesc,"supp" : $suppid},function(response)
{
$lastid=response;
if($lastid != 0)
{
alert("Product has been saved with ID=" + $lastid);
document.getElementById('resp').style.display='none';
document.getElementById('fade').style.display='none';
window.location.href=baseurl +"index.php/main/mgtprods/?key="+ $suppid;
}
});
if (remember.checked)
{
//alert($lastid);
$.post(baseurl+'index.php/main/newitem',{"prodlist" : $lastid ,"itlist" : 0,"itcost" : 0, "supp" : $suppid, "itname" : $prodname, "itunit" : "pc" },function(response)
{
document.getElementById('resp').style.display='none';
document.getElementById('fade').style.display='none';
//window.location.href=baseurl +"index.php/main/mgtprods/?key="+ $suppid;
});
}
}
太感谢了!