jQuery load external files into popup dynamically

jQuery load external files into popup dynamically

Hi everyone,

i've got a problem by loading an external html code from a file by load(...) or $.ajax(...) or XMLHttpRequest(...).
The loading of the files works exactly 2 times and then it aborts by 404.

So i tried the xhr.abort() command but unsuccessfully too. If i use a full URL like www.domain.tld/abc.html it works great. But i need this for a WebApp in Apache Cordova.

Here comes my Test-Code:

HTML:
  1.         <script src="jquery-1.9.1.js"></script>
            <script src="jquery.mobile-1.3.1.js"></script>

jQuery:
  1. var oReq;  // XMLHttpRequest object
    var id;  // id of the file which shall be opened

    function reqListener () { alert(this.responseText); };
    function transferCanceled(evt) { alert("The transfer has been canceled."); }

    $(document).on("pageinit", '#pageContent', function() {
                $(".singlePopup").on ({
                        popupbeforeposition: function() {
                            oReq = new XMLHttpRequest();
                            oReq.addEventListener("abort", transferCanceled, false);
                            oReq.onload = reqListener;
                           
                            // This line works 2 times successfully and then 404 on every file also already opened files
                            oReq.open("get", "DYNAMIC-ID.html", true);
                           
                            // This line works permanently
                            // oReq.open("get", "http://www.domain.tld/abc.html", true);
                            oReq.send();
                        },
                       
                        popupafterclose: function() {
                            $('#singleSwipe_popup').empty();
                            oReq.abort();  // close "filestream"
                        }
                });
    });    


























The same for the $('wrapper').load(...) or $.ajax ... or $.mobile.changePage functions.
I tried any jQuery and jQueryMobile version from 1.8.2 to the newest ... nothing works.

If the filepath is realy wrong, they shouldnt work on any call.