Im porting a plugin for WordPress from a script, and Im finding it very difficult to update my settings through ajax, or add new options..
I want to use ajax since my original script uses ajax.
What is the best way to approach this?
I have already read through Ajax In Plugins and all of its resources..
Here is the main structure of the plugin
myplugin/js/custom.js <- This has all the ajax requests using jQuery-Ajax
myplugin/ajax/ <- in here are all the php files that recieve the settings to be updated.
myplugin/plugin.php <- This loads the javascript file.
The javascript is loaded using :
wp_register_script( 'custom_script', plugins_url('/js/custom.js', __FILE__) );
wp_enqueue_script( 'custom_script' );
Any help is greately appreciated..
Ok it took me some time to realize how the whole thing works, but here is the deal:
You use the following example code:
Javascript
$.ajax({
type: “POST”,
url: “admin-ajax.php”,
data: {action: “DoMyAjaxStuff”}
success: function(){ }
});
PHP