Hello.
I'm not sure if anyone will be able to help me with this, because I've been unable to find a straight answer on the internet, and I thought it would be something that loads of people would want to do.
Let me make it clear I DO NOT WANT TO USE JQUERY OR ANY OTHER LIBRARIES FOR THIS. :)
Just a standard Ajax request I can dissect and learn from.
What I want to do is call a PHP function from the client using Ajax.
My example.php file:
<?php
function hello($arg){
return 'Hello '.$arg;
}
?>
HTML:
<input type="text" onkeyup="javascriptFunction(this.value)" />
And I need to be able to get and manage the response from the PHP hello() function in the javascriptFunction(). I know it is possible since the sAjax project does it, as do several other libraries/classes. These libraries have their limitations and I'd rather a barebones response so I can understand and tailor-suit it to my needs. However, I have no clue what to be sending in the request and whether it be GET or POST or Asynchronous or Synchronous etc etc.
I have some important necessities:
- Javascript libraries are a no-no. No JQUERY, Prototype, Mootools or anything else.
- The function cannot be called in the PHP file at any point.
- The PHP function must use return, not echo.
I look forward to hearing your ideas.
Thank you :)