返回的http_response错误的statusCode

问题描述

在sf2.7项目中,我很想在控制器中完成工作。

我想使用statusCode 102(HTTP_PROCESSING)将响应发送到浏览器(firefox)。 但是浏览器会收到statusCode 200。

在我的控制器中:

if($form->isSubmitted() && $form->isValid()) 
{ 
    //$checkresponse=array("status"=>"102","text"=>"Begin","url"=>""); 
    $response = new Response(); 
    $response->setContent("test"); 
    $response->headers->set('Content-Type','text/plain');  
    $response->setStatusCode(Response::HTTP_PROCESSING); 
    $response->send(); 
    $activeTab = "#SUSPECTs"; 
    //rest of the treatment
}

在我的树枝视图中

<script>
$('[name="panel"]').submit(function(e){
    e.preventDefault();
    var donnees = $('[name="panel"]').serializeArray();
    var urlsubmit = "{{path('albupol_app_panel_new_panel_criterion')}}";
    var typeSend =  $('[name="panel"]').attr('method');
    $.ajax({
        url: urlsubmit,type: typeSend,data: donnees,error: function(xhr,exception){
            alert("traitement en cours : "+xhr.status+' '+exception);
            console.log(xhr.status);
        },success: function(reponse){
            alert("traitement fini : "+reponse);
            console.log(reponse);
        }
    });
});
</script>

那确实不处理成功函数,并且响应为空(代替“测试”,我什么也没有)。 那么,如何发送带有statusCode 102的响应并显示内容

我精确地说,我们不想在其他版本的symfony中迁移该程序,而是希望在2-3年内使用其他程序。

非常感谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)