Software Archive
Read-only legacy content
17061 Discussions

window.location.href not working in ajax call.

Ian_C_
Beginner
2,496 Views

Hi all,

My app was working fine, but I upgraded XDK yesterday to version 1826 and now my App hangs in the emulator.

I tested the App in a Chrome Browser and all works fine.  Tested the App on my Android device and likewise still working, but in the Emulator its not working.

After a lot of digging I've found that the line containing "window.location.href" in a ajax function is failing.

Whats changed in the new version of XDK???

Should I be doing something different???

Strangely I have other "window.location.href" lines calling other local pages and they work.  But this function is failing and I can't see why.

Any idea???

function setDBVersionAjax() { 
    var resturl = restServerURL + "?request=dbversion";
    $.ajax({ url: resturl,
             headers: { 'Access-Control-Allow-Origin': '*' },
			 crossDomain: true,
			 dataType: 'json',
             success: function(data) {
                 localStorage.setItem('DBVersion', data.version);

                 window.location.hef = "init_db.html";
             }
    });
} 

 

0 Kudos
3 Replies
Ian_C_
Beginner
2,496 Views

Typo in my posting on the function, should have read as below

function setDBVersionAjax() { 
    var resturl = restServerURL + "?request=dbversion";
    $.ajax({ url: resturl,
             headers: { 'Access-Control-Allow-Origin': '*' },
			 crossDomain: true,
			 dataType: 'json',
             success: function(data) {
                 localStorage.setItem('DBVersion', data.version);

                 window.location.href = "init_db.html";
             }
    });
} 

 

0 Kudos
Swati_S_Intel1
Employee
2,495 Views

There is a known issue with changing to relative location during ajax call in the emulator. Your app should work fine on App Preview and with build. Please see the work around for the emulator in this thread : https://software.intel.com/en-us/forums/topic/542014

 

Swati

0 Kudos
Ian_C_
Beginner
2,495 Views

Thank you Swati...

The work around code has indeed fixed the problem.  Will this known "feature" be resolved in the next release of XDK?

Ian

0 Kudos
Reply