How can I pass a javascript variable as an variable in my php loop:
Something like this(obviously does not work):
var myJsVar = 100;
@for ($i = 0; $i<myJsVar; $i++)
... some code
@endfor
Further I tried solving this with ajax:
/**
* Get slider value
*/
$.ajax({
type: 'GET',
url: myUrl,
data: myJsVar,
success: function (option) {
console.log(myJsVar);
}
});
It returns me the success function,
Further I did this in my Controller:
public function prod(Request $request)
{
if ($request->ajax()) {
$ajax = "AJAX";
dd($ajax);
} else {
$ajaxN = "NO Ajax";
dd($ajaxN);
}
}
It did not work.
I am not sure how to proceed, hope for some help.
myJsVar? I mean it is static or come from the database or from something else ?