我想知道如何通过ajax调用php函数,如果person匹配参数显示形式。
这是我要调用的php代码,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 as $ip_range) {
if (($lngLow=ip2long($ip_range->lower)) < 0) $lngLow += 4294967296;
if (($lngHigh=ip2long($ip_range->upper)) < 0) $lngHigh += 4294967296;
if($lngIP >= $lngLow and $lngIP <= $lngHigh) {
?>
以下是我想要进行ajax调用的js:
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 to login
//Set cookie to hide the form
//utility.setCookie(name);
}
};
一旦人提交表格(如果显示)我想将数据发送到另一个php文件processer.php来处理数据。
任何帮助都非常感谢。