In this video session i have explained about Post Form data to Server in WordPress Plugin, But for that we should learn to make
ajax request, To make Ajax request Click here to learn:
By Method #1: https://www.youtube.com/watch?v=n_3nXW8VzgQ
By Method #2: 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({
submitHandler:function(){
var post_data = jQuery(“#frmPostOtherPage”).serialize()+”&action=c¶m=form_data”;
jQuery.post(ajaxurl,post_data,function( response){
var data = jQuery.parseJSON(response);
console.log(“Name: “+data.txtName+” and Email: “+data.txtEmail);
});
}
});
// By using this we serialzed form data ‘jQuery(“#frmPostOtherPage”).serialize()’ and now we are almost ready to send
data to server
‘ajaxurl’: This is the value ‘admin-ajax.php’ by admin_url(‘admin-ajax.php’);
Parameter Details:
==========================
action=custom_ajax_req
// 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_ajax_req” :
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
// and now from this file we are going to handle ‘form_data’ variable data
}
break;
}
}
¶m=get_message
// It find the executable function with this value’get_message’.
if(!empty($getParam)){
if($getParam==”form_data”){
// here we access form data.
}
}
// 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”
-~-~~-~~~-~~-~-