AJAX requests broken due to HTTPS for wp-admin
Switch to full SSL for everything. Seriously, it’s way easier than dealing with mixed content.
Switch to full SSL for everything. Seriously, it’s way easier than dealing with mixed content.
I’ve met the same issue. …the recommended Basic Auth… I found that the problem is in the Basic Auth plugin. WP-API guys recommend using their own plugin and this solution works for me. Deactivate all activated basic auth plugins in your WordPress dashboard On the machine your WordPress is running go to the plugin folder … Read more
First, you do not want to edit core WP files, because your changes will disappear when there’s an update. That’s why you are encouraged to create child themes. Second, you may want to peruse this Codex page on AJAX. Note that it shows how to handle both kinds of users (logged in and not logged … Read more
Try using .serialize() instead of FormData function step1SaveData(){ var formData = jQuery(‘#tpform1′).serialize(); console.log(formData); jQuery.ajax({ type:”POST”, url:’http://lexem.in/wp-admin/admin-ajax.php’, data:{ action:’tpartners’, formdata:formData, }, success:function(data){ var insertedID = data.trim(); if(insertedID!=’fail’){ }else{ console.log(‘fail’); } } }); } or use .serializeArray() if you want your data in an array instead of a string. EDIT – from the comments, remove processData:false and … Read more
There’s two problems: You’re not sending the AJAX request to the correct URL. You’re using PHP-style concatenation instead of JavaScript. For the first issue, a relative URL “admin-ajax.php” is not going to work. If you are on a page like /about-us/ then jQuery is going to send the request to /about-us/admin-ajax.php, which doesn’t exist. The … Read more
You shouldn’t do something like this in your JS code: url: ‘https://’+window.location.host+’/admin/admin-ajax.php’, You should use wp_localize_script and pass proper URL in there. Let’s say your AJAX call is located in file my-js-file.js. Somewhere in your theme/plugin you have something like this wp_enqueue_script( ‘<SOME_HANDLE>’, … . ‘my-js-file.js’ , …); You should add this after it: wp_localize_script( … Read more
The problem is with the AJAX endpoint URL, i.e. url: userimg.ajax_url, which is not actually defined in your JS/PHP code. More specifically, you did define the correct URL, but in the JS object, the property name is ajaxurl and not ajax_url: // wrapped for brevity wp_localize_script( ‘ajax-account’, ‘userimg’, array( ‘ajaxurl’ => admin_url( ‘admin-ajax.php’, ‘relataive’ ) … Read more
When you call admin-ajax.php no query is being produced so is_page() or is_category() or any query based conditional tag will never return true. A better way would be to include your files inside the ajax callback, meaning something like this: add_action(‘wp_ajax_PAGE_ONLY_ACTION’,’PAGE_ONLY_Function’); function PAGE_ONLY_Function(){ include TEMPLATEPATH . ‘/ajaxLoops/ajax-open_client_editform.php’; /** * do your page only ajax */ … Read more
Sidestep the entire issue and just include fo_edit_script in the header of the page, rather than in the AJAX part. There’s no need at all to do this. You might think that by only including it when its needed your optimising but your not, because it’s having to load it every time you open an … Read more
The second parameter for wp_verify_nonce() is the action. That part is not in your question, but I guess it should be called like: if ( !wp_verify_nonce($_POST[‘nonce’], $_POST[‘action’]) ){