4

I have single.php file in my theme folder and i am using ajax code in this file i have another file in same folder where i am fetching this request but its not working for me here is my jquery written in single.php

$na= jQuery.noConflict();
 $na(document).ready(function(){ 
                    $na('nav a').click(function(){
                     var nv=$na(this).text().replace(/\s/g, "_");
                     var pv=nv.toLowerCase();

             $na.ajax({
                         type: "POST",
                         url: '<?php bloginfo('template_url')?>/popupdatapdf.php',
                         data: 'valueMin='+pv,
                        success: function(result){
                                                    alert(result);
                                           }
                                      });


                });
1
  • yes the ajax requestr work but the wordpress function not supporting the file and gets the error i tried include file using require_once("project.test.com/new_test/wp-load.php"); however its still not working any solution for this? Commented Jun 13, 2013 at 13:05

1 Answer 1

2

Try something like this:

jQuery(function($){ 
    $('nav a').on('click', function(){
        var nv = $(this).text().toLowerCase().replace(/\s+/g, "_");

        $.ajax({
            type: "POST",
            url: '<?php echo get_template_directory_uri(); ?>/popupdatapdf.php',
            data: {valueMin : nv}
        }).done(function(result) {
            console.log(result);
        });
   });
});

And open the console to check for errors, also in the network tab to see that the file popupdatapdf.php is actually found in the root of the current theme.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.