I cant make it work. I have a php script on a website (not so good in php, so if something is wrong, please point me). And i want to call it from a js document.
<?php
function doit($option){
if ('getit' == $option){
$value = '318273918739182739179';
return $value;
}else{
return 0;
}
}
?>
and i want to call it from a js file. How do i pass an argument to the php script via Ajax?
var getanswer ={
php: function(){
$.ajax({
url:'mywebsite.com/php/return.php',
data: {action, 'doit'},
type: 'post',
success: function(output){
alert(output);
}
})
}
}
data: {action, 'doit'},