jQuery ajax调用不会调用我的php页面
I'm implementing Mozilla's persona authentication (ie browserid). So, I have the following onLogin():
我正在实现Mozilla的角色身份验证(即browserid)。所以,我有以下onLogin():
function onLogin(pAssertion) {
var sPHPSessionID = $.cookies.get("PHPSESSID")+'';
var sFoolCache = new Date().getTime() + '' + Math.random();
$.ajax(
{
cache: false,
type: 'POST',
url: '/webservice.php?id=personaauth&u=i',
data: { assertion: pAssertion, PHPSESSID: sPHPSessionID, z: sFoolCache },
success: function(res, status, xhr) { alert("do reload"); },
error: function(xhr, status, err) {
navigator.id.logout();
alert("Login failure: " + err);
}
});
}
Where there's the "alert("do reload")" I normally have a window.location.reload() call. The problem is that, nonetheless all my efforts to clear and not use the browser cache (Firefox), my /webservice.php page doesn't get called, at all. The ajax call immediately executes the "success" function (which keeps my window reloading in a dramatic loop, if I leave the "reload()" call in the code). I need the PHP session id in my /webservice.php call, so I pass the PHPSESSIONID cookie to the page.
哪里有“alert(”do reload“)”我通常有一个window.location.reload()调用。问题是,尽管如此,我所有努力清除并且不使用浏览器缓存(Firefox),我的/webservice.php页面根本没有被调用。 ajax调用立即执行“success”函数(如果我在代码中留下“reload()”调用,它会使我的窗口重新加载一个戏剧性的循环)。我需要在/webservice.php调用中使用PHP会话ID,因此我将PHPSESSIONID cookie传递给页面。
I cleared my firefox cache. I closed my browser, I added the 'sFoolCache' variable to the url (and not the post) but it didn't work either. I'm lost.
我清除了我的firefox缓存。我关闭了我的浏览器,我将'sFoolCache'变量添加到了url(而不是帖子),但它也没有用。我迷路了。
3 个解决方案
#1
0
Looks like there's problem with passing URL, Try passing Full URL:
看起来传递URL有问题,尝试传递完整网址:
function onLogin(pAssertion) {
var sPHPSessionID = $.cookies.get("PHPSESSID")+'';
var sFoolCache = new Date().getTime() + '' + Math.random();
$.ajax(
{
cache: false,
type: 'POST',
url: 'FullURL and QUuerystring',
data: { assertion: pAssertion, PHPSESSID: sPHPSessionID, z: sFoolCache },
success: function(res, status, xhr) { alert("do reload"); },
error: function(xhr, status, err) {
navigator.id.logout();
alert("Login failure: " + err);
}
});
}
更多相关文章
- 获取项目列表的更好方法:缓存序列化数据与数据库查询或其他?
- 如何在Safari浏览器中禁用Ajax缓存?
- IE 浏览器各个版本 JavaScript 支持情况一览表
- 我可以禁用“后退”按钮浏览器功能吗?
- 浏览器如何处理HTML元素上的无效/未指定的属性?
- JQuery纯前端导入Excel文件,兼容IE10及IE9版本以下浏览器处理方法
- 删除复制+粘贴的富文本格式? (跨浏览器)
- 如何执行浏览器内对比扩展/规范化?
- 浏览器环境下JavaScript脚本加载与执行探析之动态脚本与Ajax脚本