Instead of cooking up your own PHP file and trying to bring in WordPress functionality, put the functionality inside of WordPress using the AJAX hooks that are designed to do that sort of thing.
More info here:
http://codex.wordpress.org/AJAX_in_Plugins
Related Posts:
- Looking for a better way to handle an ajax script that pulls in post data on click
- Proper way to use WordPress function with AJAX PHP file
- How to send a php var to jQuery Ajax call with two different file
- How to check a variable Changes
- How to add elements to an empty array in PHP?
- What is the correct way to use WordPress functions outside WordPress files?
- Most efficient way to add javascript file to specific post and/or pages?
- How to correctly add Javascript in functions.php
- How can I fetch loop of post titles via AJAX?
- Pass media upload value to input field
- Where to get information about array fields in $_REQUEST?
- Pass a PHP variable to another file
- Retrieve POST data from AJAX call
- Combine CSS and JS files from plugins
- How to store the_title() into a variable to reutrn the value, not just echo it
- Variables declared in header not available in other includes
- How do I make my function add variables/values to the $post object?
- Do I require the use of nonce?
- JqueryUi Dialog giving Uncaught TypeError: this._addClass is not a function error
- Detect a focus on wp_editor
- WordPress Ajax always returns a 404 error
- Is it possible to get a theme customizer setting from wp.customize using jquery?
- Jquery no more loading, load-scripts.php not found (404)
- Removing jQuery migrate and working with dependencies
- Initialize WordPress environment to use in a real cron script
- problem with ajax and the path to the php page
- How to use wp_localize_script in a WordPress page other than functions.php?
- Real time Duplicate title check
- Load custom field value into div with AJAX
- Is there a reason why my wordpress PHP page isn’t loading into my PHP template
- Security – Ajax and Nonce use [closed]
- Refresh page after update_post_meta
- How to use WordPress (PHP) functions in AngularJS partials files?
- How to stop loading multiple copies of jquery
- Create a post variable processing page
- Jquery ajax to custom php file: returning blank data
- Cleanest/Fastest way to avoid calling and retrieving data from the database multiple times?
- jQuery functions only work on homepage
- Nice scroll to wordpress
- Update WordPress Custom Field with AJAX on cached page
- How do I add a php statement to a jQuery string
- external wordpress pages using wp-blog-header
- Bulk Image upload and one image for each post?
- Targeting single page with JS
- Infinite-Scroll Plugin and Jetpack Infinite Scroll Plugin – Adding to “Thoughts” Theme
- JS completely stopped loading but Files are found
- How can I loop into two different DIVS without repeating the DIVs
- where to include a php file
- How do I know what variables are passed in a filter/action and what their meaning is?
- Can’t use get_results() in ajax query
- Remove commas from WooCommerce checkout addresses fields
- Using an Image Slider twice on the same page
- wp_enqueue_style with style.php and WordPress functions
- Problem with WordPress Ajax form
- Click loads template via ajax
- Display notification only once
- How to retrieve the content (with a specific ID) via ajax by clicking a link tag
- Access/update database with jQuery
- How to display something in a div when the user clicks on a text in another div – no page refresh [closed]
- Passing jQuery value using Ajax to a page template
- When would you use $_post instead of $post?
- Call to undefined function issue
- Using wp_localize_script to store the template url into a variable to use in JS
- How to add a dynamic javascript snippet to the footer that requires jQuery
- Check if user is logged in when clicking certain links on certain pages
- ajax_object is not defined when ajax calls the function
- How to speed up admin-ajax.php in wordpress
- Loading jQuery in the footer after removing jQuery migrate?
- JQuery not working on WordPress Admin page [closed]
- Returning a value from a PHP page
- Why is this Ajax not working?
- Stumped – Ajax Response Returns 0
- Colorbox ajax loading of outside HTML content works perfect on localhost but not on server
- Asking popup for delete post in WordPress [closed]
- Sending jsPDF documents to the server
- Use ajax from function.php
- Ajax return code 400
- wp-load Without Loading the plugins
- wp_insert_post() is returning the correct post ID, no failure, but the post content does not get updated
- Parsing php string in jquery [closed]
- Locating Global Variables
- doing an ajax request always outputs 0
- jQuery .each to get post meta and subtract from a sum
- Pass PHP variable to JavaScript without inline JS
- Count the number of times the search form template gets included on a page
- Show post in slider
- How do i use this jquery script on a wordpress site?
- Using shipped version of jquery
- Putting PHP variables into javascript [duplicate]
- How to show a dynamic_sidebar if main content content’s height is > a set amount?
- Variable global scope [closed]
- How to test nonce with AJAX – Plugin development
- Woocommerce add to cart quantity buttons with AJAX
- How to rewrite URL with PHP variables with htaccess to a normal looking URL?
- js file in root loading without
- hover image appears below placeholder instead of overlayed
- combine Code 1 with Code 2
- WooCommerce – Reset quantity input field when variation changes
- class click counter save number
- Using a variable in is_page(array())