xmlhttprequestresponsetext

JS not loading php into div, website specific behaviour


I have two joomla applications se up with exactly the same versions, the same global configuration settings, and I set up a test application with the following function to load a php into a div on a specific page..

   function getDiv(str) {
   var id = document.getElementById("appselector").value; 
    if (id == "") {
    document.getElementById("scoffitcategoryedit").innerHTML = "";
    return;
} 
else {
    if (window.XMLHttpRequest) {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp3 = new XMLHttpRequest();

    } else {
        // code for IE6, IE5
        xmlhttp3 = new ActiveXObject("Microsoft.XMLHTTP");

    }
     xmlhttp3.onreadystatechange = function() {
        if (xmlhttp3.readyState == 4 && xmlhttp3.status == 200) {
            document.getElementById("scoffitcategoryedit").innerHTML = xmlhttp3.responseText;
            alert("WTF");
        }
    };
    xmlhttp3.open("GET","index.php?option=com_jumi&fileid=23&    format=raw&" + str + id, true);
    xmlhttp3.send();
}
}

I know its a little long winded, but the problem is that the script works fine in one website, but not in the other. Both of them are loading the same versions of jquery (which as you can see I don't like using), and both have the same templates. The only clue I seem to have found is that when I have text links elsewhere on the site attached with query statements pointing to self (index.php?blastr=bla&drivelstr=drivel), the browser shows index.php/ prepended to the link mentioned above.

I debugged the script and in the non functioning website it hangs on the xmlhttp3.send line.

I know people espouse the beauty of jquery's load() function as a replacement for this, but I cant get it to work (probably because the templates are using jquery versions higher than 1.8.1 when it was deprecated). So i'd rather stick with base js.

Any ideas about this inconsistent behaviour ?


Solution

  • I found out what it was, I must have actually installed two different versions of the Jumi application in my websites. one website had a file under components/com_jumi/views/application named view.raw.php while the other did not. This meant that the format=raw in the index.php string could not be interpreted and caused a null response.

    I simply copied the file into the other website where it was missing and everything then worked fine. But thanks for the response.