include和ajax冲突,如何使用jQuery Ajax刷新一个php include?

这是相当困难的,帮助你因你没有给我们具体的“系统”, 任何信息,你说我们的事你的cdn api ..但它是我们需要知道的不太有用的东西

所以我假设你不知道该怎么办,这里是一个普通的方法

我们的云框架意味着我们无法直接从 网站访问文件,但我可以直接包含它们。

,所以你只需要一个PHP包装来调用这些“包括”,让你的数据

// read your args and if need sanitize them

$id = $_POST['link']; // read your args

// do the job and get/generate your data

$mydata = get_responses($id, ... your api ...);

//if you need json or anything else, it's now

$mydata = json_encode($mydata);

// here print/die the data

die($mydata); // echo and return

?>

在JavaScript端,你将调用包装与所需的信息, 取决于从哪里启动该活动,您存储所需的信息

这里的一个例子,我假定这就是所谓的点击经典锚标记,并使用HREF作为args作为脚本

HTML:

my page 2

的jQuery:

// catch all anchor click

$(document).on('click','a',function(event){

var $this = $(this); // current clicked anchor as a jquery object

var href = $this.attr('href'); // get the link href

// construct your ajax args

var ajaxArgs = { link:href, hello:"world" };

/* made an ajax call by jQuery, here i use post, check jQuery documentation */

$.post('/my_php_ajax_listener.php', ajaxArgs, function(dataReturnByPhp){

/* if here ajax has terminated, do anything with the data,

* here we will fill #content html node with the data, assume data is here pure html */

$("#content").html(dataReturnByPhp);

});

event.preventDefault(); // no real click please

});

好运

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值