Place javascript processing different server
-
I have a plugin I developed using CMB to retrieve data entered in a form, process it and query a post type:
function search_and_view() { ob_start();; ?> <div class="search-form"> <form action="" id="result-form" method="post" style = "text-align:left"> <div class="form-row"> <label for="reg"> Team Reg:</label> <select type="text" id="team-reg" name="team_reg" > <option>Team 1</option> <option>Team 2</option> <option>Team 3</option> </select><br /> <label for="team-year">Term:</label> <select type="text" id="team-year" name="team_year" > <option >2015/2016</option> <option >2016/2017</option> <option>2017/2018</option> </select> <br /> <input type="submit" value="View Search Result" class="result-submit" name="result-query-submit" /> <img class="loader" src="<?php echo plugin_dir_url(__FILE__).'images/spiningball.gif' ?>" /> </form> <?php $team_vs = ob_get_clean(); return $team_vs; }
Users fill the form, submit, it’s listened to by javascript(in a separate file):
jQuery(document).ready(function($){ $('#result-form').submit(function(e){ e.preventDefault(); var team_reg = $('#team-reg').val(); var team_year = $('#team-year').val(); $.ajax({ type: 'POST', url: '../wp-admin/admin-ajax.php', data: { action: 'result_view_admin', teamreg: team_reg, teamyear: team_year, }, ...
which retrieves the variables and sends them to function(result_view_admin) to query the post type and display the corresponding query result.
Now all is working fine as it is, but I want the javascript code to run on a different server(www.myhostingserver.com) other than the one the plugin is installed on(www.usershostingserver.com). Such that users on submitting make a call to our server which retrieves the form data then responds to the function result_view_admin on the users server to query the custom post.
How do I go about this?
- The topic ‘Place javascript processing different server’ is closed to new replies.