admin管理员组文章数量:1024725
I need to click on the button to send some data to the php file and update the user's balance in the database.
quotes.js Part of the code:
var data = {
sell: sell_current_quote,
buy: bue_current_quote
};
$.ajax({
type: 'POST',
url: '/wp-content/themes/NAME/page-trading.php',
dataType: 'json',
data: data,
success: function(my_data) {
alert('Ok');
}
});
page-trading.php Part of the code:
if( isset($_POST['sell']) && isset($_POST['buy']) ) {
$sell = json_decode($_POST['sell']);
$buy = json_decode($_POST['buy']);
global $wpdb, $userdata;
$wpdb->update( PREF .'users_balance',
array(
'user_balance_2' => 100
),
array(
'user_id' => $userdata->id,
'user_schet_2' => 00000001,
),
array("%d","%d")
);
die();
}
As a result, the database is not updated. in the console, in data headers come about sell: 0.99788 buy: 0
Tell me, please, how to do it right?
I need to click on the button to send some data to the php file and update the user's balance in the database.
quotes.js Part of the code:
var data = {
sell: sell_current_quote,
buy: bue_current_quote
};
$.ajax({
type: 'POST',
url: '/wp-content/themes/NAME/page-trading.php',
dataType: 'json',
data: data,
success: function(my_data) {
alert('Ok');
}
});
page-trading.php Part of the code:
if( isset($_POST['sell']) && isset($_POST['buy']) ) {
$sell = json_decode($_POST['sell']);
$buy = json_decode($_POST['buy']);
global $wpdb, $userdata;
$wpdb->update( PREF .'users_balance',
array(
'user_balance_2' => 100
),
array(
'user_id' => $userdata->id,
'user_schet_2' => 00000001,
),
array("%d","%d")
);
die();
}
As a result, the database is not updated. in the console, in data headers come about sell: 0.99788 buy: 0
Tell me, please, how to do it right?
本文标签: Cannot transfer ajax post data from js to php file
版权声明:本文标题:Cannot transfer ajax post data from js to php file 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745614278a2159191.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论