I'm using jQuery to query a database and update a table of bid and ask prices for a currency trading ticker. I'm using $.ajax to send a currency symbol to a php script that queries the database and returns a xml document that javascript parses to make updates to the table. Everything is working in FireFox on both pc/mac and on Safari, but doesn't work in IE. The relevant code...
The jQuery making the ajax call:
var updateDataFunction = function () {
$.ajax({
url: "func2.php",
type: "GET",
data: "symbol=<?php echo $stock; ?>",
dataType: "xml",
success: function (msg) {
var bid = $('bid',msg).text();
var ask = $('ask',msg).text();
var spread = $('spread',msg).text();
// do some other stuff
}
});
};
The script uses php to place the stock in the javascript before the javascript is run. The updateDataFunction gets called in a $(document).ready.
The php script
<?php
header("content-type:text/xml;charset=utf-8");
// connect to the database
function GetUpdate($symbol) {
$query = "SELECT * FROM tblSG WHERE strSymbol='$symbol'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)) {
$spread= $row['fBid'] - $row['fAsk'];
$output="<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<exchange>\n";
$output.="<bid>" . number_format($row['fBid'],4) . "</bid>\n";
$output.="<ask>" . number_format($row['fAsk'],4) . "</ask>\n";
$output.="<spread>" . number_format($spread,4) . "</spread>\n";
$output.="</exchange>";
}
return $output;
}
$symbol = $_GET['symbol'];
echo GetUpdate($symbol);
?>
Using POST instead of GET causes it to fail in FF and Safari as well. Any ideas on a solution to this?