> my JS book tells me that I have to check for ActiveXObjects or something then do two different things depending on what it returns
Used to be true. But even MSIE 7 supports the standard way now. So you would only need to worry about it if you want to support MSIE 6 and before. Ancient history.
I don't know what query you want to make of your PHP code. You mentioned a product id? What will your PHP send back? Just a "YES/NO" response or info about the product?
But something like this:
Code:
function ajax( prodid )
{
// if you want to support MSIE 6 and 5:
var http = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
// if you don't care about IE 6 and 5:
var http = new XMLHttpRequest();
// rest same no matter what:
var url = "http://www.yoursite.com/yourpage.php?productid= " + encodeURIComponent(prodid);
http.open( "GET", url, true );
http.send( );
http.onreadystatechange = function( )
{
if (http.readyState==4)
{
document.getElementById("productDetails").innerHTML =
http.status == 200 ? http.responseText : "Error getting details: " + http.status;
}
}
}
Would you really drag in the entire jQuery library just to replace that simple code?