[wp-trac] [WordPress Trac] #46721: admin-ajax not working correctly
WordPress Trac
noreply at wordpress.org
Fri Mar 29 15:30:46 UTC 2019
#46721: admin-ajax not working correctly
--------------------------------+-----------------------------
Reporter: beaconmartinb | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Administration | Version: 5.1
Severity: major | Keywords: needs-codex
Focuses: ui, administration |
--------------------------------+-----------------------------
So According to the Codex and a 12 Gold Badge wordpress.stackexchange
member the following code should work, but it does not I think there is a
bug in the add_action handler for 'wp_ajax' because the action is never
being run.
So this is my simple test case:
{{{#!php
<?php
class testClass {
public function __construct(){
echo "hello world";
add_action('wp_ajax_beacon_podio-get_apps', array($this,
"get_apps"));
}
public function get_apps(){
if(isset($_POST['app_id'])){
$app_id = $_POST['app_id'];
die("Request is valid");
}else{
die("Invalid request");
}
}
}
new testClass();
}}}
Testing with request to from browser with logged in admin account:
/wp-admin/admin-ajax.php?action=wp_ajax_beacon_podio-get_apps
Expected Result
{{{
hello worldInvalid request
}}}
Actual Result
{{{
hello world0
}}}
The question an answer that made me think this is a bug:
https://wordpress.stackexchange.com/questions/332878/wordpress-ajax-
action-how-to-return-content
--
Ticket URL: <https://core.trac.wordpress.org/ticket/46721>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list