Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9203187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:25:02+00:00 2026-06-17T23:25:02+00:00

i’ve done an ajax request in my wordpress plugin.My request is based on steps

  • 0

i’ve done an ajax request in my wordpress plugin.My request is based on steps below:

1) i am including js file and starting a request document on ready

2)At the php side i want to take this request and print it to test.

for all these stuff i wrote these codes:

main.js:

 $(function(){      
    $.post('/wp-content/plugins/dsn/functions.php',{token:"1tibu4"},function(data) {
      console.log(data);
    },"json");
 });

functions.php:

 <?php 

   add_action('loop_end', 'init');

   function init(){
       global $_POST;

       $post= $_POST;   
       echo json_encode($post);Exit;

   }

My question is when request complete there is nothing on the response tab of console screen.How come this happen?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:25:04+00:00Added an answer on June 17, 2026 at 11:25 pm

    WordPress has a unique way of handling AJAX. If you make a request to the php file directly, then you are not loading the rest of the WordPress framework and a lot of WordPress specific functionality will not be available to you.

    In the PHP side, what you have to do is use code that looks like this:

    //for logged in users
    add_action('wp_ajax_my_action', 'my_action_callback');
    //for not logged in users
    add_action('wp_ajax_nopriv_my_action', 'my_action_callback');
    
    function my_action_callback() {
      //your function here
      exit; //always call exit at the end of a WordPress ajax function
    }
    

    In the JS side, you need to send your request to a file called “wp-admin/admin-ajax.php”

    So your request would look like this (using jQuery):

    $.ajax({
        url : '/wp-admin/admin-ajax.php',
        type : 'get', //or 'post'
        data : {
                    action: 'my_action_callback'
                }
    })
         .fail(function(r,status,jqXHR) {
             console.log('failed');
         });
         .done(function(r,status,jqXHR) {
            console.log('success');
         });
    

    Note the my_action_callback parts.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.