javascript - Access Wordpress ajax on external host -


i'm building html/js app turn mobile phonegap based on wordpress site (using database, users, etc.). right have index.html functions.js tries access function created on wordpress

add_action('wp_ajax_nopriv_checking_email', 'checking_email'); 

what want able access js code. i've tried this:

jquery.ajax({     type: 'post',     url: 'http://myhost.com/wp-admin/admin-ajax.php',     data: { 'action': 'checking_email', 'email': 'email@example.com' },     success: function(request_data) {         console.log(request_data);     } }); 

and

xmlhttprequest cannot load http://myhost.com/wp-admin/admin-ajax.php. no 'access-control-allow-origin' header present on requested resource. origin 'null' therefore not allowed access.

what can access admin-ajax.php external host?

so, after testing bit more found pretty silly fix. changing header on server's script allowed access different host.

header('access-control-allow-origin: *'); // host header('access-control-allow-origin: myhost.com'); // specific host 

Comments