2013-04-26 26 views
-1

您好,我有一個AJAX功能,我不能夠重定向到我需要的控制器CakePHP中AJAX功能不是重定向到其它頁面

$.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..... 
} 

以及如何更改輸出格式?

任何人都可以幫我用我的代碼?

+0

該死的,在這裏發帖之前仔細檢查語法錯誤! – 2013-04-26 10:08:19

+0

請修正語法錯誤並提供更多詳細信息,如其他答案/評論中所述。 – Akshay 2013-04-26 10:22:47

+0

有任何CSRF保護。在你的網站?可能會自動將隱藏的標記字段插入到表單中,然後檢查並阻止 – 2013-04-26 10:26:04

回答

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. 
     } 
     }); 
相關問題