doubiaozhan0745 2010-10-10 14:15
浏览 50
已采纳

如何在没有与Ajax一起使用的重定向的情况下从不同的php页面请求数据?

So I have this one CakePHP web application that I'm trying to refactor.
There is a large portion of code that usually works like this:
E.g. "Flag":
User clicks flag button
Redirect the user to the flag action
Flag action flags post
Redirect user to post that was just flagged.

I am also trying to enhance it with JavaScript like so:
User clicks flag button
Javascript makes AJAX request to that action
Call returns with a status that JS inteprets

Is there some way to streamline this sort of flow so that it is easily testable and can be covered with a javascript that doesn't need redirection?

  • 写回答

1条回答 默认 最新

  • duanjuda5789 2010-10-10 14:25
    关注

    Lookup jQuery's .post() function. That lets you post to a URL and handle (in a callback function) whatever results the server returns. The server can return some simple data to indicate success or failure, or it can return an HTML fragment to be placed somewhere on the page (under control of your Javascript code), or really anything else you want.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏