【问题标题】:ajax function not redirecting to other pageajax函数不重定向到其他页面
【发布时间】:2013-04-26 10:01:23
【问题描述】:

嗨,我有一个 ajax 函数,但我无法在 cakephp 中重定向到我想要的控制器

$.ajax( {
    type: "POST",
    url:  "/NewEvents/some_function",
    data:array,
    async: true,
    success: function (data) {
    alert('hello');
}

NewEvents 是我的控制器,some_function 是我希望数据去往的地方...

// In my controller file
 function some_function()
 {
       some code.....
 }

以及如何更改输出格式??

谁能帮我写代码??

【问题讨论】:

  • 你缺少右括号});
  • 该死的,在这里发帖之前仔细检查语法错误!
  • 尝试提供您的应用程序的 URL,例如 /your_app/NewEvents/some_function。还可以查看 Firebug 的控制台面板,看看您的脚本中是否有任何错误。
  • 请更正语法错误并提供更多详细信息,如其他答案/cmets中所述。
  • 有任何 CSRF 保护。在您的网站上?可能会自动将隐藏的token字段插入到表单中,然后检查并阻止

标签: php jquery ajax cakephp


【解决方案1】:

在成功完成ajax请求后使用ajax成功函数按照下面给出的代码,

$.ajax( {
        type: "POST",
        url:  "/NewEvents/some_function",
        data:array, //data you want to pass the
        success: function (data) {
        alert('hello'); // after success hello will alert.
        }
        });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-01
    • 2012-03-16
    • 2018-07-10
    • 1970-01-01
    • 2023-04-09
    • 2021-11-06
    相关资源
    最近更新 更多