Support the ongoing development of Laravel.io →
posted 8 years ago
Views

Hi guys, I just want to ask how to use Ajax in Laravel 4.2, because everytime I used simple Ajax and returning the result from other php file, my page always crashing.

Here's my example code:

<div id="getData"></div>


<script>
	function display(){
		xmlhttp = new XMLHttpRequest();
		xmlhttp.open("GET", "select.php", false);
		xmlhttp.send(null);
		document.getElementById("getData").innerHTML = xmlhttp.responseText;
	}

	display();

	setInterval(function(){
		display();
	}, 500);
</script>

The select.php file echo data from the database (e.g. 354)

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

webman0317 webman0317 Joined 19 Oct 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.