PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, March 2, 2022

[FIXED] How to detect if it is an AJAX request in WordPress?

 March 02, 2022     ajax, php, wordpress     No comments   

Issue

Is there anyway to detect if the current server operation is currently an AJAX request in WordPress?

For example:

is_ajax()

Solution

Update: since WordPress 4.7.0 you can call a function wp_doing_ajax(). This is preferable because plugins that "do Ajax" differently can filter to turn a "false" into a "true".


Original answer:

If you're using Ajax as recommended in the codex, then you can test for the DOING_AJAX constant:

if (defined('DOING_AJAX') && DOING_AJAX) { /* it's an Ajax call */ }


Answered By - webaware
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing