How can I render errors/success messages I got from the server with laravel and AMP here is an example but it doesn't work I get undefined variable
server side (laravel)
public function userAjaxHasNotLogedIn()
{
return response()->json(['loged' => false], 400)
->header('AMP-Access-Control-Allow-Source-Origin',"http://localhost:8000");
}
the function is working fine and it return a json file with the variable loged
client side (AMP)
<div submit-error>
<template type="amp-mustache">
<a style="cursor: pointer;" id="submitloginbtn" on="tap:loginform.show,submitloginbtn.hide" > Réessayer </a>
</template>
</div><div submit-success>
<template type="amp-mustache">Vous êtes connecté {{ loged }}</template></div>
the error Use of undefined constant loged - assumed 'loged'
It seems you are trying to use blade syntax with javaScript. you can do like this. use @
with blade @{{logged}}
<div submit-error>
<template type="amp-mustache">
<a style="cursor: pointer;" id="submitloginbtn" on="tap:loginform.show,submitloginbtn.hide" > Réessayer </a>
Vous êtes connecté @{{ loged }}