One of the pages in my application has a set of links that when clicked, posts form data based on the TableTools jQuery plugin. I'd like this new page to open up in a new window. Any ideas on the best way to do this? I'd rather not change all of my action links over to individual forms and use target="_blank"
. I've tried calling a new window to open on success, and posting writing the data to this page, but that hasn't been working. Please help!
HTML:
<div id="action">
Download
</div>
Javascript:
$('#action').click( function () {
var userData = oTable.fnGetColumnData(0);
$.ajax({
type: "POST",
url: "../download.php",
data: "user_list=" + userData,
dataType: "json",
success: function(data){
var win = window.open();
win.document.write(data);
}
})
})
Answer: Use the jQuery submit() Method You can use the submit() method to submit an HTML form (i.e. <form> ) using jQuery. The jQuery code in the following example will submit the form on click of the button (i.e. the <button> element) which has the type attribute set to button (i.e. type="button" ).
For Sending or inserting or saving multiple data in single click then you have to use Jquery and javascript code. By using Jquery or Javascript code you can generate dynamic HTML field in your HTML form. We can generate any dynamic HTML field by using Jquery and append into your form fields.
Found the answer:
jQuery.ajax success callback function not executed
When I took out the dataType: "json"
, it worked!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With