Support the ongoing development of Laravel.io →
posted 10 years ago
Requests

I'm trying to query a restful webservice written in laravel using $.getJSON (jquery). But the cross origin request is blocked.

This is what I've in larvel:

Route::get("/fakedata", function(){
$utenti = [];
for($i=0; $i<100; $i++){
	$utenti[$i] = new \stdClass();
	$utenti[$i]->nome = "nomeutente".$i;
	$utenti[$i]->cognome = "cognome".$i;
	$utenti[$i]->indirizzo = "indirizzo".$i;
	$utenti[$i]->telefono = "telefono".$i;
}
return Response::json(["utenti"=>$utenti])->setCallback(Input::get('callback'));
 });

In js:

 $.getJSON("http://mysite/fakedata")
Last updated 3 years ago.
0

solved using:

 $.getJSON("http://mysite/fakedata?callback=?")
Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

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.