Call Php function through Ajax -
i want know how call php function through ajax , if person matches parameters display form.
here php code want call, microsub.php:
<?php $ip = $_server['remote_addr']; $public_ip_ranges = array(); $range = (object) array(); $range->name = 'xxxx xxxxx'; $range->lower = '10.1.0.0'; $range->upper = '10.1.255.255'; $public_ip_ranges[] = $range; $range = (object) array(); $range->name = 'xxxxxxx'; $range->lower = '141.228.0.0'; $range->upper = '141.228.255.255'; $public_ip_ranges[] = $range; $range = (object) array(); $range->name = 'xxxxxxxxx'; $range->lower = '146.127.0.0'; $range->upper = '146.127.255.255'; $public_ip_ranges[] = $range; if (($lngip=ip2long($ip)) < 0) $lngip += 4294967296; foreach ($public_ip_ranges $ip_range) { if (($lnglow=ip2long($ip_range->lower)) < 0) $lnglow += 4294967296; if (($lnghigh=ip2long($ip_range->upper)) < 0) $lnghigh += 4294967296; if($lngip >= $lnglow , $lngip <= $lnghigh) { ?>
below js want make ajax call:
var utility = require('./utility.js'); var extend = require('extend'); var $ = require('jquery-browserify'); module.exports = { init: function() { utility.consolelog('micro trial form init!'); //utility.getcookie(name); //check if cookie set //**ajax call here** //display ip form $('#rdm-below-header').append( "<p>micro trials form</p>" ); //on submit form via ajax //on success hide form, show success message ask login //set cookie hide form //utility.setcookie(name); } };
once person submits form(if displays) want send data php file processer.php process data.
any please appreciated.
Comments
Post a Comment