pass ajax request in wordpress page

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);
                                           }
                                      });


                });

Related posts

Leave a Reply

1 comment

  1. 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.