我想用POST数据打开一个新窗口/选项卡,但是它不起作用

时间:2019-10-16 17:13:33

标签: javascript ajax

这是通过PHP生成的调用之一:

                    <script>
                      var copyrecipient = [];
                      var customhintcopy = [];
                      copyrecipient.push('customer');
                      copyrecipient.push('healthinsurance');
                      customhintcopy.push('4');
                      customhintcopy.push('6');
                      $.ajax({
                      type: "POST",
                      url: "./content/pdf-view-bill.php",
                      data: {
                         bills: '6',
                         copyrecipient:copyrecipient,
                         customhintcopy:customhintcopy,
                         additionaltextcopy: '',
                         copycoveringnotes: '5',
                         documentationcopy: '1',
                         original: '1'
                      }
                      success: function(data){
                          var win = window.open();
                          win.document.write(data);
                      }
                    })</script>

控制台在“成功行”上引发“未捕获的SyntaxError:意外的标识符”,我不知道为什么。 我想要的是要打开的新窗口或选项卡,该窗口或选项卡将发送我上面定义的数据。 有人可以帮助我吗?我是Ajax的新手...

1 个答案:

答案 0 :(得分:-1)

您错过了}对象的data上的逗号。

data: {
    bills: '6',
    copyrecipient:copyrecipient,
    customhintcopy:customhintcopy,
    additionaltextcopy: '',
    copycoveringnotes: '5',
    documentationcopy: '1',
    original: '1'
}, // <-- Here
success: function(data){
    var win = window.open();
    win.document.write(data);
}