我很困惑。請幫幫我。爲什麼laravel5中的json響應中有meta標記
我有這樣的Java腳本代碼:
$(document).ready(function(e) {
$('#requestButton').click(function(e) {
$.ajax({
type: "POST",
dataType:"json",
data:{job:'propertyCreation' },
url: "/testajax", //Relative or absolute path to response.php file
success: function(data)
{
alert(data.responseText);
},//success
error:function(e){
alert(e.responseText);
}
}//ajax
);//ajax
});
});
在我的控制器Testajax功能是負責上述Ajax請求回答到。
public function testajax(Request $request)
{
if ($request->isMethod('post')){
$result=array('success'=>true,'response'=>$_REQUEST['job']);
\t return json_encode($result);
}
}
我預期的反應是
{"success":true,"response":"propertyCreation"}
,但反應
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
{"success":true,"response":"propertyCreation"}
我困惑爲什麼在JSON響應meta標籤,結果有錯誤沒有成功。對不起,我的英語不好,並提前謝謝
非常感謝您的回答。我的代碼在我的其他項目中正常工作,但在當前項目中發生此問題。我不知道我必須做些什麼才能解決這個問題 – loghman
就在現在,我也在清晰的Laravel 5.1上進行了測試,這也沒關係。 也許在一些中間件的原因? – Slam
非常感謝您的關注和測試。再次感謝。我發現我的錯誤。 – loghman