Why is the API looking for a non-existing jQuery module?

2641
6
12-23-2014 11:34 AM
DennisHunink
New Contributor III

Hi There!

my implementation of the JS API is failing because dojo is trying to fetch a (non-existing) jQuery.js module on https://js.arcgis.com/3.12/jquery.js.

Does anyone know any causes for this particular error?

Schermafbeelding 2014-12-23 om 20.29.55.png

A little more details:

The implementation is done on a Wordpress website, were jQuery is included by default. See it in action at https://tpgrf.nl/testserver/alpha/topotrainer/provincies/  To narrow down the possible causes I created a simple WordPress page with just the js api included: https://topografieindeklas.nl/pocdojo/. Same problem here.
The problem started to occur only after the recent update of WordPress. No WordPress plugins are causing the problem, since it continues to be present, even if all plugins are disabled. A version running WordPress 4.0.1 is live here: https://topografieindeklas.nl/topotrainer/provincies/

Any help would be appreciated!

Tags (1)
0 Kudos
6 Replies
ReneRubalcava
Frequent Contributor

Try adding this before the first instance of require in your code.

define.amd.jQuery = false;

It looks like jQuery is loading after the EsriJS and jQuery has a line of code in it's loader that looks like

"function"==typeof define&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){...

I've done this to load jQuery via AMD, but the opposite by setting it to true, so maybe setting it to false will help. Not sure.

And for the record, your second wordpress link doesn't throw an error in Chrome for me.

0 Kudos
DennisHunink
New Contributor III

Hi Rene! Really appreciate your quick reply!

I've implemented your suggestion as follows:

<link rel="stylesheet" href="https://js.arcgis.com/3.12/esri/css/esri.css">
<script type="text/javascript">var dojoConfig = {parseOnLoad: true, isDebug: true, async: false};  </script>
<script src="https://js.arcgis.com/3.12compact/"></script>       
<script type="text/javascript">define.amd.jQuery = false;</script>

Unfortunately this doesn't solve my problem, see the screenshot below (Chrome Console):

Schermafbeelding 2014-12-23 om 21.09.07.png

0 Kudos
ReneRubalcava
Frequent Contributor

That's odd. It could be timing issue. You could try moving the require() statement inside the the jQuery(document).ready(function($) {}) method, still setting define.amd.jQuery = false; If I step through with breakpoints at the jQuery(document), $("#selectProvinceListShortcode") and require() and wait a sec between each breakpoint, your map and page load without errror, so I'm thinking that means the timing is off with those.

Actually, it worked without even setting the define.amd.jQuery = false, so you could probably remove that if it works in the ready method.

I would probably go a step further and move all your jQuery stuff inside the the require method, don't even worry about jQuery(document) as the dojo/domReady! module does the same thing.

DennisHunink
New Contributor III

That sounds interesting! Could you share the code you used with the pauses at the various breakpoints?

I'll just go from there and dive further in it.

0 Kudos
ReneRubalcava
Frequent Contributor

I'm using Chrome DevTools and placed breakpoints at those three lines I mentioned.image.jpg

0 Kudos
DennisHunink
New Contributor III

Weird. I don't seem to get it running....

Anyway, I just restored an backup from a couple of days ago in a different folder: Oefen de Topografie van Nederland per provincie

That one works like a charm. Only thing I've changed since then is upgrading WordPress from 4.0.1 to 4.1. I do believe you're right about the timing issue. Does it makes any sense to you, comparing the restored backup to the false website on https://tpgrf.nl/testserver/alpha/topotrainer/provincies/ ?

0 Kudos