I have PHP function:
public function doit()
{
$arr1= array();
$arr1['index1'] = 'value1';
$arr1['index2'] = 'value2';
}
I call it from my JQuery function:
$.ajax
({
url: "/controller/doit",
success: function()
{
alert('done!');
}
});
Everything I want is – that my JQuery function, which contains this ajax call will return me the array, which is identical to the one, which PHP function returned (the only difference is language of course: JS instead of PHP)
You need to return something from your doit function.
Edit:
Jquery to PHP: When the javascript is run, it will send the data array to the server using the url. The server receives the array, encodes it as json and sends it back to the success callback function which will log the data to the console.