WordPress Insert not working with ajax

Your AJAX callback method should be outputting something followed by a die() statement. function wp_insert() { ..your code echo $whatever_your_results_are; // die(); } I would also recommend against prefixing your custom methods with wp_. That should be reserved for WordPress and will cause confusion to other developers – and probably you 6 months down the … Read more

click event to unhide something after ajax not firing

Your button was added dynamically. So you can not bind event in simple way. As button is added after DOM is fully ready. You need to bind it with the refrence of document or body jQuery(document).on(‘click’, ‘#readmore’, function(e){ e.preventDefault(); alert(“you clicked the button”); jQuery(“#bodytext”).css(“display”, “block”); }); Read more about it here

Ajax call through admin-ajax.php returns 404 error

success and error are functions, not properties of AJAX function. Working code: $(“.tabs .btn”).click(function(e) { e.preventDefault(); $.ajax({ url:”/wp-admin/admin-ajax.php”, type: “GET”, dataType: “html”, cache: false, data: { action: “shows” } }) .success(function(resp) { $(“.ajax-show”).append(resp); }) .error(function(xhr, status, error) { var err = JSON.parse(xhr.responseText); console.log(err); }); }); Also that should be noted: Deprecation Notice: The jqXHR.success(), jqXHR.error(), … Read more

Angular not defined [closed]

You should use wp_enqueue_script to add the script. The documentation contains information about the function and how it should be used and some helpful examples. Basically, you will need to add something like this to the functions.php file: function myextension_enqueue_scripts() { wp_enqueue_script( ‘myextension-angular’, plugins_url( ‘/assets/js/angular.min.js’ , __FILE__ ), // If you are working on a … Read more

Null/undefined return in WordPress AJAX request

I am not sure the output you have provided is the correct one but do you notice the ‘0’ character at the end of your string? {“title”:”R=3+”,”dates”:[“06\/04\/2014″,”11\/05\/2014″,”15\/06\/2014″,”27\/07\/2014″,”17\/08\/2014″,”28\/09\/2014″,”05\/10\/2014″,”19\/10\/2014″,”09\/11\/2014″,”23\/11\/2014″,”14\/12\/2014″],”series”:[{“data”:[[1396738800000,284],[1399762800000,350],[1402786800000,212],[1406415600000,296],[1408230000000,220],[1411858800000,253],[1412463600000,200],[1413673200000,310],[1415491200000,180],[1416700800000,156],[1418515200000,290]],”name”:”Bulls”}]}0 That is enough to cause the JSON parser to fail. Also, don’t use the contentType property like that since you don’t send any JSON, you should remove that … Read more