我有一个使用 jQuery ajax 提交的表单,它工作正常,但我还需要提交第二个数据源。
这就是我到目前为止所拥有的:
<script type="text/javascript">
var $j = jQuery.noConflict();
$j(window).load(function(){
// this is the ID of your FORM tag
$j("#send-form").submit(function(e) {
e.preventDefault(); // this disables the submit button so the user stays on the page
// this collects all of the data submitted by the form
var str = $j(this).serialize();
$j.ajax({
type: "POST", // the kind of data we are sending
url: "<?php print $cs_base_dir; ?>sendmail.php", // this is the file that processes the form data
data: str, sData, // this is our serialized data from the form
success: function(msg){ // anything in this function runs when the data has been successfully processed
// this sets up our notification area for error / success messages
$j("#note").ajaxComplete(function(event, request, settings)
{
if(msg == "OK") // Message Sent? Show the Thank You message and hide the form
{
// This is shown when everything goes okay
result = "<div id=\"message\" class=\"updated\">Your message has been sent.</div>";
}
else // if there were ewrrors
{
result = msg; // msg is defined in sendmail.php
}
$j(this).html(result); // display the messages in the #note DIV
});
}
});
});
});
</script>
但是我还需要提交一些其他数据(数据表),这些数据是通过以下方式获得的:
var sData = $j('input', oTable.fnGetNodes()).serialize();
这是指定如何发送它的页面:DataTables with form elements example
如何添加它以便提交表单和数据表?
谢谢 C