Reputation: 2099
Here is what I try to achieve: Let's say i have two files, order.php and print.php. In order.php there is a button for printing some data. When user clicks the button I want to post some data from order.php to print.php. Easy. But how?
This is my last attempt to do this.
$.ajax({
type: 'POST',
url: '../event/print',
async: false,
data: {json:$("input[name=json]").val(),id:"2"},
success:function(data){
myWindow = window.open('../event/print', "_blank");
myWindow.focus();
},
error:function(data){
swal("Oops...", "Something went wrong.", "error");
}
It shows me error alert everytime with 500 Internal Server Error. What I'm doing wrong?
EDIT I've changed some things around the web, and now it does not show any error. But I cant see any $_POST parameters.
Upvotes: 3
Views: 11381
Reputation: 1057
In this way you are calling the page ../event/print twice.
The first time as a POST request via AJAX, the second time as a GET request due to the fact that you are opening a new tab.
What you are describing is not an AJAX request, it is just a form with target="_BLANK".
http://www.w3schools.com/tags/att_form_target.asp
<form action="../event/print" method="post" target="_blank">
...
Upvotes: 1