0

I'm trying to accomplish a JavaScript form that will load the result from a PHP request on an external website, after a text box is filled out.

Right now, I have

    <script type="text/javascript"/>
function sendrequest() {
document.location="myphpsite.com/submit.php?tb="+document.getElementById("tb").value;
}
</script>
<form>
<input type="text" id="tb" onChange="sendrequest()" />
</form>

This code is going nowhere, because from my current knowledge, you can only load PHP variables on startup, by using "script src=... ", and by having the php page return some javascript code.

What I'm looking for is a way to request/receive php variables dynamically, something that would work like this:

    <script type="text/javascript">
function getdata() {
return document.get("myphpsite.com/submit.php?tb=hi");
}
</script>

In other words, is there a function that dynamically "reads" a website, and returns the raw text?

jtst
  • 312
  • 4
  • 16

2 Answers2

1

http://w3schools.com/ajax/default.asp

You should go read this and then read it again, AJAX is what you need.

George
  • 36,413
  • 9
  • 66
  • 103
1

best example with PHP and AJAX -

http://www.w3schools.com/php/php_ajax_database.asp

Jatin
  • 1,668
  • 2
  • 16
  • 23