Problem addressing php back to div

Terryf51

New member
Hi everyone this is my first post so please be gentle with me...

I have an html form with a div id called TextResult

I can get my code to work in html and javascript as below:
Code:
<script LANGUAGE=Javascript>         
     var xhttp = new XMLHttpRequest();
     xhttp.onreadystatechange = function() {
     if (this.readyState == 4 && this.status == 200) {
           document.getElementById("TextResult").innerHTML = this.responseText;}};
     xhttp.open("GET", "test.php", true);
     xhttp.send();
</script>
However if anyone views source they can see the name of the php script which will eventually contain login information for the server.
Hence I want to hide the php declaration and call it sort of server side.

Now what I want to try however this is in pseudo code and will not work... is...
Code:
<script LANGUAGE=Javascript> 
     var xhttp = new XMLHttpRequest();
     xhttp.onreadystatechange = function() {
     if (this.readyState == 4 && this.status == 200) {
           document.getElementById("wb_txtJS").innerHTML =      [b] <?php require('test.php'); ?>[/b]             ;}};
     xhttp.open("GET", "test.php", true);
     xhttp.send();
</script>

I may be being silly but I need to hide the script and return the result to the div as in the top javascript code.
Thank you in advance fro any feedback.
I am a newbie to PHP.
 
I just had a good result - I've solved my own problem after three hours!

Code:
<script LANGUAGE=Javascript>             //wb_Text2//
	document.getElementById("wb_Text2").innerHTML = "<?php require('test.php'); ?>";
</script>

This calls the php script - remains hidden from 'view source' and returns the result from test.php back to the div..

SO thank you - i've included my solution here for anyone with the same issue, and to solve the issue.
 
Back
Top