我有一个修改表格' wp_postmeta'的元内容的表单。我试图找出从表单到INSERT到另一个表的操作的方法。
这可能吗?这就是我所拥有的,并且数据不会插入到事务表中。
CURRENT FORM提交按钮div:
<div class='inventory-management-form-item-holders inventory-management-submit-holder'>
<input type="submit" name="submit" value="SUBMIT">
</div>
&#34;库存同治提交&#34; js SECTION:
// submit form
jQuery("#submit").click(function(){
// Change thw loading Gif url
jQuery('#the-results-holder').html("<img src='/wp-content/plugins/mcs-inventory-management/assets/images/loading_icon.gif' />");
jQuery.ajax({
type: "POST",
data: {'im-product-id': theProductId, 'status-quantity': jQuery('#status-quantity').val(), 'status-action': jQuery('#im-action-box').val(), 'status-location': jQuery('#status-location').val(), 'status-move-location': jQuery('#status-move-location').val()},
dataType: "json",
url: "/inventory-management-process/",
processData: true,
success: function(data) {
jQuery('#the-results-holder').html("");
jQuery('#status-stock').val(data.stock);
jQuery('#status-res').val(data.res);
jQuery('#status-prepro').val(data.prepro);
jQuery('#status-clean').val(data.clean);
jQuery('#status-quantity').val("0");
},
error: function (xhr, ajaxOptions, thrownError) {
jQuery('#the-results-holder').html("");
jQuery('#the-results-holder-error').html("There has been an error!");
}
});
return false;
});
这是我在哪里尝试执行INSERT表单进入事务表的内容?
<form name='inventory-management' id='inventory-management-form' method="POST" action='<?php $transaction ?>'>
<?php
$product= $_POST['part-number'];
$action= $_POST['status-action'];
$from_location= $_POST['status-location'];
$to_location= $_POST['status-move-location'];
$qty= $_POST['status-quantity'];
if(isset($_POST['submit']))
{
$transaction = "INSERT INTO mcs_inventory_transactions (id,product,action,from_location,to_location,qty) VALUES ('','$product','$action','$from_location','$to_location','$qty')";
$result = mysql_query($transaction);
}
?>
答案 0 :(得分:0)
将你的js改为
JS
// submit form
jQuery("#inventory-management-submit").click(function(){
// Change thw loading Gif url
jQuery('#the-results-holder').html("<img src='/wp-content/plugins/mcs-inventory-management/assets/images/loading_icon.gif' />");
jQuery.ajax({
type: "POST",
data: {'im-product-id': theProductId, 'status-quantity': jQuery('#status-quantity').val(), 'status-action': jQuery('#im-action-box').val(), 'status-location': jQuery('#status-location').val(), 'status-move-location': jQuery('#status-move-location').val(),submit: "test"},
dataType: "json",
url: "/inventory-management-process/",
processData: true,
success: function(data) {
jQuery('#the-results-holder').html("");
jQuery('#status-stock').val(data.stock);
jQuery('#status-res').val(data.res);
jQuery('#status-prepro').val(data.prepro);
jQuery('#status-clean').val(data.clean);
jQuery('#status-quantity').val("0");
},
error: function (xhr, ajaxOptions, thrownError) {
jQuery('#the-results-holder').html("");
jQuery('#the-results-holder-error').html("There has been an error!");
}
});
return false;
});
希望这有助于你
答案 1 :(得分:-1)
这是错误的:
$transaction= if(isset($_POST['submit']))
应该是
if(isset($_POST['submit']))