First of all you should read the codex on AJAX_in_Plugins
Secondly you should look at wp_localize_script to get the value for the admin-ajax url to your javascript.
$data = array(
'ajax_url' => admin_url( 'admin-ajax.php' )
);
wp_localize_script( 'ajax-script', 'ajax_object', $data );
In your javascript, you are then meant to reference the localized data
jQuery(".selectbox").change(function(){
var id = this.id;
// do a POST ajax call
$.ajax({
type: "POST",
url: ajax_object.ajax_url,
data: ({
"action": "get-mata-value",
"metakey": id
}),
success: function( response ) {
}
});
});
Related Posts:
- My javascript is returning this error: $.ajax is not a function
- Can’t get a JSON object in response to an Ajax request with wp_ajax
- Infinite scroll / lazy loading with NextGen Gallery [closed]
- Ajax call does not activate callback function
- Trying to get single posts to load on the front page via ajax
- Ajax not firing properly using Firefox, but works in Chrome
- How to Use JSON With AJAX?
- Using wp_ajax and wp_ajax_nopriv hooks
- wp_ajax unauthenticated and authenticated
- WordPress customizer refresh screen after save
- Loading posts via AJAX in a hidden div with updated URL?
- Correct way to write jQuery functions in WordPress
- WooCommerce Ajax Cart Update Stopped Working
- How to Dynamically Load Content Into Body of Bootstrap Modal Window?
- Trouble with WordPress Ajax Login System – 302
- videopress videos are not displayed when loading the content with ajax in a lightbox
- How to return multiple arguments from AJAX callback function
- url – ajax loaded but no JS
- Ajax Validation for reCaptcha
- Properly embed javascript into WP (using function.php) – doesn’t work?
- Custom AJAX form not working async
- WordPress Insert not working with ajax
- AJAX Success Function using JS substr() fails in WP 4.1 vs 4.0
- Is there some jQuery conflict here?
- Change Query Arguments (filter) with jQuery/Ajax or PHP?
- Ajax page load in wordpress the right way?
- Orderby post__in Not Working Correctly?
- Get ajaxForm response value
- Retrieve customizer value using ajax or customizer api and print the value in theme
- Displaying contents of a tab
- Ajax Query returns zero
- Widget won’t work due to old JavaScript? Any ideas how to make it work? [closed]
- How to set time delay in javascript
- JavaScript: filter() for Objects
- What does on() in JavaScript do?
- Ajax Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource
- jQuery Ajax POST example with PHP
- Enable & Disable a Div and its elements in Javascript
- SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
- The ‘describe’ keyword in javascript
- Enable Submit Comment Without Page Reload (Using Ajax)?
- Add tinymce buttons to caption textarea in media uploader
- Ajax Load More Posts in Category Page
- WordPress Ajax URL for function in functions.php
- Move WordPress native javascript to bottom of page?
- AJAX function returning -1
- jQuery AJAX form validation
- Custom plugin giving: wp-admin/admin-ajax.php 400 (Bad Request)
- Proper way to load a single post via Ajax?
- How to load whole WordPress pages dynamically with AJAX/jQuery like this following website?
- Creating custom AJAX requests
- How to pass jQuery ajax URL value
- how to get the comment ID in the front end when the REPLY button is clicked?
- How to create popup same as wordpress popup feature
- Gravity Forms not loading under https, jQuery is not defined
- Admin wp_ajax hook returning 0
- How to speed up admin-ajax.php in wordpress
- wp_verify_nonce not working
- Tags in WordPress 3.2
- php ajax problem – weird 301 responses!
- Create URL with parameter for JQuery toggle status
- Not sure why wp_ajax isn’t working?
- Load created php file data via ajax
- Ajax Modal Flickers When Opened Multiple Times
- WordPress Ajax problem with undefined url
- Add a class to posts in increments of 2
- Intergrating agile carousel to wordpress: how to write the ajax_callback function
- Return an array from get_terms and store as JavaScript array for search autocomplete
- WP http XML response HTML encoding and image display problems
- Using WP_Query to grab custom meta values, foreach to json object
- Add/remove action on jQuery toggle
- Javascript stopped working [closed]
- Why load JS through the CMS framework? [duplicate]
- delete post meta by AJAX
- how to json_encode(); the Loop content so that the encoded array is [“0”:content, “1”:content]
- How to keep HTML form field that is conditional hidden with javasript hidden after page reload?
- Accessing javascript in multiple files [closed]
- Why i can’t get custom fields value or post ID via Ajax?
- Issues loading Jquery on WordPress website
- No Object Properties sending form through AJAX
- Redirect wp_dropdown_pages() to an AJax request?
- click event to unhide something after ajax not firing
- how to use wp_editor() here am getting empty result
- Accessing an API with jQuery and AJAX
- Parse wordpress blog data using json api and ajax
- Problem adding MP3 attachments to a jPlayer playlist
- problems with jquery external rss feed integration
- AJAX calendar navigation returns -1
- A carousel slideshow plugin in JavaScript
- How to call a function from functions.php with ajax?
- Ajax post doesnt call succes after got the response
- Colorbox not working on native WordPress gallery when gallery is loaded thru AJAX
- Adding scripts before plugins scripts
- jQuery search function not running in WordPress but running locally (fiddle)
- Autocomplete for titles via ajax – rework of past post away from like_escape()
- Ajax Request with jQuery not happening
- Contact Form 7 submission does not complete [closed]
- Combo box populating a DIV using ajax/jquery
- Infinite Scroll applied to ajax loaded content
- Carousel Hover Image