我正在尝试使用jQuerys post-function将表单发布到CakePHP脚本.
像这样:
jQuery的:
$('#submit_btn').click(function(){
//Code to prevent redirect
dataString = 'test=testdata';
$.post('cakephp/forms/output', dataString, function(response){
alert(response);
})
});
Run Code Online (Sandbox Code Playgroud)
CakePHP的
function output(){
pr($this->data); # Print nothing
pr($_POST); # Print test => testdata
$this->render('view','ajax'); # Render ajax-friendly
}
Run Code Online (Sandbox Code Playgroud)
所以$_POST不是空的但是$this->data......怎么样?
发布数据的表单元素i来自aja,如果这是在这种情况下重要的事情.