Closing ajax function file with die() causes error and empty page

The die should be in your show_article() function. Yours is out, so the whole script is terminated. Your function should be: function show_article(){ $q = $_GET[‘getid’]; echo strval($q); die; } or function show_article(){ $q = $_GET[‘getid’]; exit( strval($q) ); }

wp_localize_script not create variable in head section

Your code looks correct. alert(wp_ajax.nonce); should display the nonce. You can also verify the existence of the wp_ajax object via console.log(wp_ajax) in your browser’s Javascript console. wp_localize_script adds the object(s) to the footer (a call to wp_footer() should be present in the theme’s footer.php file). It’ll look like so: <script type=”text/javascript”> /* <![CDATA[ */ var … Read more

load plugin with ajax [duplicate]

looking at the html output of the plugin code, i can say u that the plugin loads everything else (textarea and history) with javascript (see all those data- attributes and loading message). Now if the call to function was made on page load(non-ajaxy way), the plugin would have loaded requried javascript files and then things … Read more