View Single Post
Old 06-30-2009, 08:29 PM   #6 (permalink)
Hades
Moderator
 
Hades's Avatar
 
Join Date: 01-23-07
Location: Buenos Aires, Argentina
Posts: 1,210
iTrader: 0 / 0%
Hades is a web professional of the highest orderHades is a web professional of the highest orderHades is a web professional of the highest orderHades is a web professional of the highest orderHades is a web professional of the highest orderHades is a web professional of the highest orderHades is a web professional of the highest orderHades is a web professional of the highest orderHades is a web professional of the highest orderHades is a web professional of the highest orderHades is a web professional of the highest order
Hi,

I just tested your code (except the PHP side since I don't have your DB) and it seemed to work for me by changing 1 line change in the JS:

My hard coded php was:

output.php
PHP Code:
<?
echo json_encode("<p>Total Square Feet: 123</p>
        <table style=\"width: 100%;\">
         <tr>
          <td><div style=\"background-color: #000000; line-height: 2px;\">&nbsp;</div></td>
          <td style=\"font-weight: bold;text-size: 14pt; width: 20px;\">OR</td>
          <td><div style=\"background-color: #000000; line-height: 2px;\">&nbsp;</div></td>
         </tr>
        </table>
        <p>Individual Square Feet per Section:
        <table style=\"width: 100%;\">
         <tr>
          <td>Front Bumper: 0.25</td>
          <td>Rear Bumper: 0.86</td>
         </tr>
         <tr>
          <td>Hood: 0.25</td>
          <td>Roof: 0.25</td>
         </tr>
         <tr>
          <td>Rear Side: 5.26785</td>
          <td>Front Side: 77.678625</td>
         </tr>
         <tr>
          <td>Sides: 8.825</td>
          <td>Mirrors: 0.2445</td>
         </tr>
         <tr>
          <td>Back Window: 0.21241245</td>
          <td>Side Windows: 0.4645725</td>
         </tr>
        </table></p>"
);
?>
request.php
HTML Code:
<html> <head> <script> var xmlhttp; function loadXMLDoc(url) { xmlhttp = null; var returntxt = ""; if (window.XMLHttpRequest) xmlhttp = new XMLHttpRequest(); else if (window.ActiveXObject) xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); if (xmlhttp != null) { xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4) { if (xmlhttp.status == 200) { alert(xmlhttp.responseText); returntxt = json_parse(xmlhttp.responseText); } else alert("Problem retrieving XML data"); }else{ } }; xmlhttp.open("GET", url, true); xmlhttp.send(null); return returntxt; } else alert("Your browser does not support XMLHTTP."); } function request(){ loadXMLDoc("output.php"); } </script> </head> <body> <input type="button" value="REQUEST!" onclick="request();"> </body> </html>
The only change I made on your script was the 3rd argument on the xmlhttp.open function

HTML Code:
xmlhttp.open("GET", url, false);
changed to:
HTML Code:
xmlhttp.open("GET", url, true);
It displays the content of output.php page with the numbers and decimals correctly. Maybe your issue was the JS?
__________________
Hades,
Ancient god, King of the Nether World, and Guardian of the Dead.
...and on my free time I'm also a web developer, contact me if you need one!
Hades is online now   Reply With Quote