Call PHP function with jquery $.ajax return json Call PHP function with jquery $.ajax return json json json

Call PHP function with jquery $.ajax return json


You can just put that one function in a PHP file alone. Then run the function within that file (so it echoes out the JSON). Have ajax call that file.

In your case:

echo a($string);


If you were willing to explore an alternative to Jquery, there is a tool called XAJAX that allows you to directly call PHP functions asynchronously via AJAX. It's a pretty nifty tool, though the support and forums are a bit cryptic. For those who are hardcore PHP (but not JAVASCRIPT) guys, this tool is a great option.