net::ERR_INSUFFICIENT_RESOURCES
Hi i am getting this error. Here is my javascript code
<script>
function getAllSamrats(){
$.ajax({
url: "/samrat",
success: function( response ) {
$('#total-samrat').text( response );
}
});
};
setInterval(getAllSamrats, 30);
</script>
<script>
function getAllYuvarajs(){
$.ajax({
url: "/yuvaraj",
success: function( response ) {
$('#total-yuvaraj').text( response );
}
});
};
setInterval(getAllYuvarajs, 30);
</script>
<script>
function getAllMaharajs(){
$.ajax({
url: "/maharaj",
success: function( response ) {
$('#total-maharaj').text( response );
}
});
};
setInterval(getAllMaharajs, 30);
</script>
<script>
function getAllSamanths(){
$.ajax({
url: "/samanth",
success: function( response ) {
$('#total-samanth').text( response );
}
});
};
setInterval(getAllSamanths, 30);
</script>
It simply means your browser runs out of memory due to making too many ajax calls...
Why don't you embed this into one function and make one call instead of 4 at one time?
<script>
function getAllSamrats(){
$.ajax({
url: "/all",
success: function( response ) {
$('#total-samrat').text( response.samrat );
$('#total-yuvaraj').text( response.yuvaraj );
$('#total-maharaj').text( response.maharaj );
$('#total-samanth').text( response.samanth );
}
});
};
setInterval(getAll, 30);
</script>
and in your controller just return them as json? for example in laravel
public function all() {
$data = [
'samrat' => getSamrats(),
'yuvaraj' => getyuvarajs(),
'maharaj' => getmaharajs(),
'samanth' => getsamanths()
];
return response()->json($data);
}
additional to be honest with you why are you refreshing every 30 seconds?
are you waiting for an action to happen at the other end so you keep checking ?
If so i would recommend using vueJS and pusher for this sort of stuff as it takes a lot of pain from coding all of this in Jquery
@JeffreyWay has made a great tutorials here at laracasts on vuejs and pusher be sure to check them out!
Please or to participate in this conversation.