阿贾克斯调用同一个函数的多个PHP文件 [英] Ajax calling multiple php files in same function

查看:149
本文介绍了阿贾克斯调用同一个函数的多个PHP文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,前几天我问这个问题 <一href="http://stackoverflow.com/questions/25454114/session-data-displaying-url-of-$p$pvious-picture">Session数据显示URL previous图片

So, few days ago I asked this question Session data displaying url of previous picture

这是工作,但没有任何方法来调用多的事情在同一时间?

It is working, but is there any way to call multiple things at same time?

我有counter.php和report.php,他们都是从getRandom.php访问会话数据。

I have counter.php and report.php, they are both accessing session data from getRandom.php.

function Refresh()
{
$('#picturehere').load('getRandom.php', function(){$load('report.php');});
};

我刷新()code。 我想在自己的div显示counter.php,这是可能的吗?

My Refresh() code. I want to display counter.php in its own div, is this possible to do?

当我试图分开我counter.php在其自己的行类似这样的错误获取会话数据,从previous图片。

When I try to separate my counter.php in its own line like this its getting wrong session data, from previous picture.

function Refresh()
{
$('#picturehere').load('getRandom.php', function(){$load('report.php');});
$('#counter').load('counter.php');
};

感谢。

推荐答案

有没有必要作出3种不同的HTTP请求/ AJAX调用获得来自同一服务器的信息。

There is no need to make 3 different http requests / ajax calls to get information from the same server.

您应该做一个Ajax调用,并结合在服务器端的脚本或有一个脚本包含其他脚本。然后,你可以结合在一个数组或对象和 json_en code()的输出数据它回浏览器发送。在那里,你可以得到不同的部分并根据需要将它们放在不同的HTML元素。

You should make one ajax call and combine the scripts on the server side or have one script that includes the other scripts. Then you can combine the output data in an array or object and json_encode() it to send it back to the browser. There you can get the different parts and put them in different html elements as desired.

您可能需要移动到多一点完整的方法,如 $。阿贾克斯() ,而不是仅仅使用 .load()虽然。

You might need to move to a bit more complete method like $.ajax() instead of just using .load() though.

这篇关于阿贾克斯调用同一个函数的多个PHP文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆