此axios功能有时无法使用symfony

时间:2019-01-17 16:05:32

标签: javascript axios symfony4

这是我的功能javascript:

$(".domaine").click(function (e) {

    axios.interceptors.request.use(function (config) {

    axios.get(url).then(function(response){

       console.log(response);
     .......

    })




})

刷新浏览器时,它会给出正确的数据结果(在控制台中):

..... 
 data: {master: Array(1), licence: Array(2), var: 
"here"}

经过一段时间的停用后,执行相同的功能会得出:

data: "<!DOCTYPE html>↵<html>↵    <head>↵       
<meta charset="utf-8">↵  

在控制器中,我有:

/**
 * @Route("home/specialite/{id}", name="specialite_lus_mus")
 */
public function index($id)
{




    $Lus = $this->getDoctrine()
    ->getRepository(Licence::class)
    ->findBySpecialite($id);

    $Licences = new TableJson();
    $arrayLicence=$Licences->construct_table($Lus);


    ///$Mus the same code of $Lus


    $Masters = new TableJson();
    $arrayMaster=$Masters->construct_table($Mus);

     $var="here"; 
      return new JsonResponse(['master'=>$arrayMaster, 'licence'=>$arrayLicence, 'var'=>$var]);


}

0 个答案:

没有答案