逻辑更改URL到达方法jQuery



我正在尝试将get url转换为jQuery中的帖子URL,我需要逻辑帮助。

我的代码:

//Code need to change
var url = '/index.php?page=invoice&action=InvoicePrint&from=print&invoiceid='+Invoiceid;
    window.open(url, "_blank");
//My new code:
var url = '/index.php?page=invoice&action=InvoicePrint&from=print&invoiceid=' + Invoiceid;
            $('<form action="'+url+'" target="_blank"></form>').appendTo('body').submit();
  1. 我无法使用Get方法,因为IN发票ID(ex:1000个ID,例如1,2,3,4,5,6,7),所以我正在更改为发布ID的帖子方法。

  2. 我通过将表格附加到身体上时会面临问题。检查上面的代码"我的新代码:"。该表格已发布到

index.php?

但是是:

index.php?page =发票&amp; action = invoiceprint&amp; for = print&amp; invoiceid = 1,2,3,4,5,6,7

,但没有任何附加在URL上。

是的,我用相同的GET方法测试。一旦URL帖子起作用,我将转换O帖子方法。因为只有" incoiceid"我试图发布所有其他获取方法保持不变。

谢谢

尝试添加表单的方法aTribute,例如

<form action="'+url+'" method="post" target="_blank"></form>

更新了,但是您无法将数据存储在URL中。帖子应在主体中发送参数,而不是在URL中发送参数。因此,您的URL应该像'/index.php'。并且您的参数应该在身体中,因此请在形式的隐藏字段中添加所有页面,操作等。

<form action="/index.php" method="post" target=...>
   <input type="hidden" name="action" value="InvoicePrint"/>
    ............
</form>

或使用jQuery Post

$.ajax({
   type: "POST",
   url: '/index.php',
   data: data,
   success: success
});

white数据是所有参数的对象

最新更新