"Backendless is not defined"

Hi,

I just started migrating my app to Backendless 4.x. Everything seems to be working on most of my team’s computers, but we’re suddenly unable to pull up the website on 1 machine. Both Chrome & Safari are throwing errors.

Chrome:

Your data cannot be processed. Please refresh the page. Error message: Uncaught ReferenceError: Backendless is not defined

Safari

Your data cannot be processed. Please refresh the page. Error message: ReferenceError: Can't find variable: Backendless

Does anyone know what the problem is here? We haven’t changed a single character of code.

Thanks,
Casey

Hi Casey,

How do you reference the Backendless library/js in your code?

Regards,
Mark

Mark,

In the head of our index.php file, we reference it via a simple script tag:

<<script src="http://api.backendless.com/sdk/js/v3/backendless.min.js"></script>

Above that, we have another script that reads:

document.addEventListener("DOMContentLoaded", function(event) {
Backendless.initApp(.....

Casey,

Version 4 of the Backendless backend requires that you use version 4 of the library. Here’s the doc:
https://backendless.com/docs/js/doc.html#setup

Regards,
Mark

Ah yes. But the site is still running on v3 of Backendless, so that library should still work.

And, it does on everything except that one machine

If you call Backendless.initApp before the js is loaded, it would explain the error.

Huh. Any idea why it wasn’t a problem before?

I am not sure, but the sequence certainly makes sense (load library first, then start using it).

Agreed. And now it seems to be working.

Thanks Mark!