WordPress Plugin Development tutorial from scratch (Part 13) Simple Ajax Request in WordPress

In this video session i have explained about Simple Ajax Request in WordPress, Basically there are many ways to do this task, it is one of them, Another way you can also from here, Click here to learn: https://www.youtube.com/watch?v=RAwahYG8Qfc

#WordpressTutorialsPoint
#WordpressLearnersHub
#WordpressCustomizations
#LearnWordpressStepbyStep
#WordpressBySanjay

Steps to do this task:
#1: Make HTML form from where we will make server request.
#2: Make use of javascript to link with library file of server
#3: Handle the Client request
#4: Send response of Client Request

First we make html form ,
===============
We have added some data fields

Make use of javascript ‘post’ method
===============
// other ajax request
jQuery(“#frmPostOtherPage”).validate({ // function for client side validation
submitHandler:function(){
var post_data = “action=custom_plugin_library&param=get_message”;
$.post(ajaxurl,post_data,function(response){
console.log(response);
});
}
});

Parameter Details:
==========================
action=custom_plugin_library
// It attaches the library file with client request

if(isset($_REQUEST[‘action’])){ // it checks the action param is set or not
switch($_REQUEST[‘action’]){ // if set pass to switch method to match case
case “custom_plugin_library” :

add_action(“admin_init”,”add_custom_plugin_library”); // match case
function add_custom_plugin_library(){ // function attached with the action hook
global $wpdb;
include_once PLUGIN_DIR_PATH.”/library/custom-plugin-lib.php”; // ajax handler file within /library folder
}

break;

}
}

&param=get_message
// It find the executable function with this value’get_message’.

if(!empty($getParam)){
if($getParam==”get_message”){
echo json_encode(array(
“name”=”Online Web Tutor”,
“author”=”Sanjay Kumar”
));
die;
}
}

// library file to use validate() method:
https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.16.0/jquery.validate.min.js

How we add custom javascript code to wordpress plugin page:
==============================
Click here to watch:

SOCIAL :
===============
Subscribe : https://www.youtube.com/channel/UCB2flCo-gW6RhpVVXySqcMg
FACEBOOK : https://www.facebook.com/onlinewebtutorhub/
TWITTER: https://twitter.com/owthub
BLOG: https://onlinewebtutorhub.blogspot.in/

RECOMMENDATION:
===============
1. Some knowledge of PHP, HTML for this video series
2. How to Install WordPress: https://www.youtube.com/watch?v=MREgql9jmf0

Also you can learn WordPress Custom
===============
Theme Development: https://www.youtube.com/watch?v=MREgql9jmf0&list=PLT9miexWCpPV9WxY_QG3qxUGKzw54LboW
Widget Development: https://www.youtube.com/watch?v=ZSbdYG1svV8&list=PLT9miexWCpPUgibUXDZ7JP1j3U-m61U8m

Tags
===============
online web tutor,
profotech solutions,
wordpress plugin development from scratch in hindi,
wordpress plugin development from scratch in easy steps,
wordpress plugin development,
wordpress plugin development in easy steps,
plugin development in wordpress from scratch in hindi,
plugin development in wordpress by online web tutor,
plugin development in wordpress tutorials from scratch in hindi,
plugin theme development tutorials in hindi,
plugin development tutorials in hindi,
owt tuts,
online web tutorials,

Thanks
Online Web Tutor
Keep learning and Sharing 🙂

-~-~~-~~~-~~-~-
Please watch: “Learn backbone.js tutorial from scratch”

-~-~~-~~~-~~-~-

About admin

Leave a Reply

Your email address will not be published. Required fields are marked *