Come posso ottenere $ .gescript per funzionare correttamente?
-
14-11-2019 - |
Domanda
Posso vedere che il bit $ .gettiscrit di JQuery sarebbe utile una volta che funziona, ma è l'ultimo piccolo piccolo che sto avendo problemi con.Sospetto che il problema sia causato dal modo in cui sto caricando i file JS.Come faccio a lavorare?Il mio indice.html è in realtà indice.php e ha pochissimo tra i tag del corpo.Sto usando jQuery 1.7.1
<body id="btLive">
<script>
buildInterfaces();
</script>
</body>
.
Buildinterfaces () risiede all'interno di un documento denominato layoutloader.js.In quel file, ho quanto segue:
$(document).ready(function() {
$('#hToggle').click(function() {
aaa = "Not working.";
$.getScript('test.js', function() {
alert(aaa);
});
toggleHoverPanel();
});
});
.
Come test, test.js è nella stessa cartella di layoutloader.js e contiene solo quanto segue:
aaa = "Successful Load."
.
Quando clicco sul pulsante HTGGAGLE, TOGGLEHOVERPANEL ha luogo e non ottengo alcun avviso.Se metto un avviso dopo Aaa="non funziona".;Ho l'avviso che mi aspetto, dicendomi che non funziona.Ho un numero di elementi che ho bisogno di usarlo, ma per la vita di me, non riesco a farlo funzionare.Aiuto?
Soluzione
With high probability test.js file could not by found. Add this piece to your code and try again:
$(document).ajaxError(function(event, request, settings){
alert('error loading: ' + request.status);
});