weixin_33730836 2011-03-28 10:06 采纳率: 0%
浏览 49

如何实现div中的ajax身份验证?

大家好。

我正忙于我的第一个AJAX Web编程,我想要它加载一个php文件(索引),然后xmlhttprequest能够加载和刷新div内容的想法,而无需刷新页面。

到目前为止,一切运行良好,大约有4个div部分根据按下的菜单按钮(全部通过getdata函数和xmlhttprequests)可以获得不同的内容。

此外,我还想整合一个额外的强化div,并尝试使用login.php、用户名和pass的输入字段来实现一个很好的jquery淡入淡出系统;以及一个process_login.php,它将数据与mysql进行比较并返回是否匹配;最后是一个安全页面,用户在成功授权后可以登出该页面。

但是当我直接在浏览器中直接加载login.php时,这些页面似乎无法正常工作。

当我在login.php上使用getdata和xmlhttprequest将其加载到index.html的div部分中时,不再起作用了,因为似乎无法再使用在login.php上声明了的功能页面。

阅读ajax的虚拟变量并没有给我任何答案,尽管我确信对此事实必须有一个易于理解的逻辑解释。

我实在无法理解......

  • 写回答

2条回答 默认 最新

  • weixin_33744854 2011-03-28 10:14
    关注

    As to why.....I dont know why this behaves so.

    However as to a fix/workaround. Im in a similar situation currently where im loading in pages (actually asp/jscript rather than php). What ive discovered is that the scripts you write in the page thats being loaded in, are not available anymore when loaded through AJAX. I have experienced the same problem if the page being loaded contains an applet or other html object type of tag.

    A solution to this is to move your scripts to an external file on the server, from there your page will be able to reach them regardless of whether it was loaded by AJAX as a panel or is a standalone page

    Example: (this is obviously jscript rather than php but the loading will be similar.) Page login.asp contains in <head>

    <script type="text/javascript" src="scripts.js"></script>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配