Ajax - 'ajax_url' => admin_url( 'admin-ajax.php' ) POST 400 (Bad Request). #208
Obi-nine
started this conversation in
Coding (HTML, PHP, CSS, JS)
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm currently trying to use ajax with Oxygen builder, but I get POST 400 (Bad Request).
I have created a plugin to use as a function.php.
I'm using this code to use the PHP code, but Oxygen Builder seems to block the usage of admin-ajax.php.
"
wp_enqueue_script(
'cartajax',
plugin_dir_url( FILE ). 'assets/js/cartajax.js',
array('jquery','featherlight'),
false,
false
);
add_action( 'wp_ajax_nopriv_custom_price', 'custom_price' );
add_action( 'wp_ajax_custom_price', 'custom_price');
function custom_price() {
//require('price_algo.php');
//$rawData = file_get_contents("php://input");
die();
}
wp_localize_script( 'cartajax', 'my_ajax_object',
array( 'ajax_url' => admin_url( 'admin-ajax.php' ) )
);
"
Has anyone had the same issue and found a solution to this?
I have searched everywhere but haven't been able to find a solution.
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions