Javascript 在中发送额外参数。提交
您好,我有一个函数,我正在使用ajax尝试获取一些值,然后提交一个php表单,如下所示Javascript 在中发送额外参数。提交,javascript,php,jquery,ajax,forms,Javascript,Php,Jquery,Ajax,Forms,您好,我有一个函数,我正在使用ajax尝试获取一些值,然后提交一个php表单,如下所示 /* form-horizontal */ $attributes = array("class" => "form-horizontal", "id" => "register_form"); if (isset($_SESSION['login'])) { if ($_SESSION['login'] == 'DoBusinessPerformed'
/* form-horizontal */
$attributes = array("class" => "form-horizontal", "id" => "register_form");
if (isset($_SESSION['login']))
{
if ($_SESSION['login'] == 'DoBusinessPerformed' || $_SESSION['login'] == 'NormalPerformed') {
echo form_open('myprofile/ManageProcessNew/'.$pathName, $attributes);
} else {
echo form_open('myprofile/RegisterProcessNew/'.$pathName, $attributes);
}
}
else
{
echo form_open('myprofile/RegisterProcessNew/'.$pathName, $attributes);
}
正如您所看到的,我有一个.$pathname,它是一个参数,其中包含值'borrow',这是我调用的ajax函数,用于发送此表单
self.checkMangoPayId = function(){
$.ajax({
type: 'POST',
url: BASEURL + 'index.php/myprofile/checkMangoPayID/' + auth,
contentType: 'application/json; charset=utf-8',
})
.done(function(data) {
console.log(data);
if(data.mangopay_id == null){
alert("going to save page for mango id");
// here is where I submit the form
$("#register_form").submit();
}else{
self.mangoPayIdCheck(true);
self.showModalAddId();
}
})
.fail(function(jqXHR, textStatus, errorThrown) {
alert("Error code thrown: " + errorThrown);
})
.always(function(data){
});
}
我要做的是在.submit函数中添加一种方法来更改.$path name的值,并将借来的内容改为借来的内容
我尝试了很多方法,如.submit(借用),但这些方法都不起作用,因此基本上我只想在路径名中向接收此参数的控制器发送一个不同的值。在提交之前,您可以添加如下属性
$("#register_form").attr('action',BASEURL + "index.php/bla/bla/borrowed");
然后当您提交时,它将作为参数附加在后面。我真的不明白您想做什么。但是,如果您试图发送一个额外字段作为表单的一部分,那么您可以在HTML表单中添加一个隐藏字段,并在调整它之前设置它的值。