jquery - Uncaught ReferenceError: Main is not defined javascript -
i having bit of trouble calling function 1 javascript file another.
the call search.js file using
main.userroleteam({ teamdropdown: $("#team"), teamroledropdown: $("#teamrole"), memoryload: true, load: function (options) { } });
the other file main.js
function userroleteam(options) { ... }
in dev, works in test, not.
the folder \ file structure same , have checked this.
i have used diff tool @ solution \ folder \ file differences , there nothing.
in aspx page files being called so.
<script src="../static/search.js" type="text/javascript"></script> <script src="../static/main.js"type="text/javascript"></script>
i have check other answers on here, , tried various solutions, of state order of calling files should above.
================================================
edit 1
looking @ page source, values should expecting in sourcecode,
<div class="user text-right"> <b>user:</b><span id="username">adrian wright</span><br /> <b>team:</b><select name="team" id="team"> <option value="4" data-roles="agent|agent">cps</option> <option value="5" data-roles="manufacturer|manufacturer">tej</option> <option value="3" data-roles="supplier|supplier">sha</option> </select> <br /> <b>role:</b><select name="teamrole" id="teamrole"> </select> </div>
but selection list isnt populating, value.
again, code same in dev in test dev working, test not.
your function window.userroleteam
, not window.main.userroleteam
.
to correct change function declaration to:
var main = main || {}; main.userroleteam(options) { ... }
secondly make sure declared before being called. need reorder javascript references:
<script src="../static/main.js"type="text/javascript"></script> <script src="../static/search.js" type="text/javascript"></script>
i'm not sure why works locally, shouldn't be, unless have other code in dev supporting this.
fyi - adding functions file called main.js
doesn't make function exist under main
object.
Comments
Post a Comment