I have a working AJAX file that will execute the content in a PHP file. However, if the php is within the function(there are alot of php funtion in a PHP file), how do I call only the function that I want.
My AJAX code:
$(document).ready(function(){
// use ajax, call the PHP
$.ajax({
url: 'postme.php',
success: function(response){
$('.result_Postme').text(response);
}
})
});
one of the function in postme.php PHP file:
<?php
function echo()
{
echo 'Text';
}
?>
Thanks.
EDIT:
@Amadan hi, i tried ur method but it doesn't seems to be outputting in the html.
My AjAx code:
$(document).ready(function(){
// use ajax, call the PHP
$.ajax({
url: 'rank.php',
data: {
action: 'echo'
},
success: function(response){
$('.rank_Alibaba').text(response);
}
})
});
PHP file
switch($_REQUEST['action'])
{
case 'echo':
echo "text";
break;
}
HTML:
<td class="rank_Alibaba"></td>