I'm having problem with my code below:
jquery
var data = $('thisForm').serialize();
var msg = <?php echo computeAverage(data)?>;
alert(msg);
php
function computeAverage($data){
return $data;
}
I'm getting " data"(string) as the output and not the actual value of data. By the way, I only use one php file that contains the jquery and php function above.
Your help will be appreciated. I really need to figure this out. I'm new to jquery.
thank you for your replies. given that i need to place my php function to a separate file
jquery
var url = "myPhpFunction.php";
var data = $('thisForm').serialize();
$post(url,data, function(response)); // how can i get the reponse from my url?
php
function computeAverage($data){ // how to convert $data to an array?
return average; // how can i return the average back to my jquery?
}
can anyone help me? thanks