Problems with getting background-image using Javascript in IE and Chrome
<p>I have a site that allows users to tag pictures. Tags can be voted on. I have two options for sorting tags: "sort top" and "sort new", which is pretty self explanatory. When the user clicks on, for example, "sort new", this JS function is called:</p>

<pre><code>&lt;script type="text/javascript"&gt;
    function sortTagsNew()
    {

    var sortnew = document.getElementById('sortnew');
    var sorttop = document.getElementById('sorttop');
    sortnew.style.textDecoration = 'underline';
    sorttop.style.textDecoration = 'none';
    var filename = document.getElementById('center_frame').style.backgroundImage;

if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
{
document.getElementById("response_caption").innerHTML=xmlhttp.responseText;
}

}
 xmlhttp.open("GET","sortnew.php?filename="+filename,true);
 xmlhttp.send();


}
&lt;/script&gt;
</code></pre>

<p>You can probably tell that that big IF statement does an AJAX call. It refers to the following PHP file, <code>sortnew.php</code>, which queries the database for tags under that image.</p>

<pre><code>$capfilename = $_GET['filename'];
$acturl = substr($capfilename, 6, -3); //extracts filename from the url('')

$new_captions = mysql_query("SELECT * from captions where image = '$acturl' ORDER BY  time DESC LIMIT 5");
$caption = array();
while($rows = mysql_fetch_array($new_captions)){
$caption[] = $rows;

// Includes a PHP file that designates how tags should be displayed (uses a foreach), but that's kind of irrelevant.
</code></pre>

<p>What I think the problem is, is that IE and Chrome aren't getting the <code>filename</code> through. When I manually input a filename for a valid image with tags, it works fine, but for whatever reason, IE and Chrome don't get the filename and as a result, don't return anything. I think it might have something to do with how I use the substring to extract the filename itself. Maybe Chrome and IE automatically get the filename, but I couldn't find anything about that. Keep in mind that it <strong>does</strong> work in FF.</p>
