Including another php file inside ajax call works but javascript file doesn't load -
I have a form wizard php
page and in its related javascript (I'm an experimental prototype. JS BTW), I am updating a division with Ajax.Updater
. What is really interesting is that the external php file is successfully included but the Javascript file is not. Here's my code:
wizard.php
& lt; Div id = "step1" class = "tab-panel active" & gt; & Lt; H3 square = "block" & gt; & Lt ;? = $ Core-> L ("report_selection")? & Gt; & Lt; / H3 & gt; & Lt; Div class = "control-group" & gt; & Lt; Label class = "control-label" & gt; & Lt ;? = $ Core-> L ("report_name")? & Gt; & Lt; Span class = "required" & gt; * & Lt; / Span & gt; & Lt; / Labels & gt; & Lt; Div class = "control" & gt; & Lt; Id = "report_selection" field = "report_selection" class = "m-wrap span10" apieter = "true" & gt; & Lt ;? = Combo_creator :: render_reports_by_authorization () ;? & Gt; & Lt; / Select & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div id = "step2" square = "tab-panel" & gt; & Lt ;! - Here I show the external php file I am in Ajax call - & gt; & Lt; / Div & gt;
wizard.js
select report selection: function () {switch (this.reportSelection.getValue ()) {Case A: New Ajax. Updateor ('step2', get_report_type.ajax.php, {parameters: {report selection: select it.portate.get value}}, interrupted: function () {this.reportLastConsumptionFilter = new report LastConsumptionFilter (this);}}) ; break;
and within the AJAX get_report_type.ajax.php
switch ($ report_selection) {case A: $ include_page = "Last_cons_report.php"; break; } If (isset ($ include_page)) {echo $ include_page is included; }
last_cons_report.php
& lt ;! - Some HTML elements - & gt; ... & lt; Script type = "text / javascript" src = "script / report last consumption filter.js" & gt; & Lt; / Script & gt;
All this works well but as you can see I add a Javascript. The problem is that my Javascript file is not included in my main file, anything is fine.
Can you see this problem?
Edit: Solution
Select report: function () {switch (this .reportSelection.getValue ()) {case A: New Ajax Updater ('step2', get_report_type.ajax.php, {parameters}: {reportSelection: this.reportSelection.getValue ()}, interactive: jQuery.getScript ("script / reporting / aircom consolidation / report eric commonsfunction filtering.js", function ( ) {Warning ("script loaded and executed");});}}); break;
Ajax not loaded & lt; Script & gt;
Tag file, here's the problem, this line is just ignored by Ajax. Consider using the JavaScript function to import your javascript code.
This is a code in your code using a
function load script (URL, callback)
:
report Select: function () {switch (this.reportSelection.getValue ()) {Case A: New Ajax. Updater ('step2', get_report_type.ajax.php, {parameter: {reportSelection: This.reportSelection.getValue ()}, interrupted: function () {load script ("script / report last consensus filter.js", function () { // callback code is here.}) This.reportLastConsumptionFilter = New ReportLastConsumptionFilter (this);}}); break;
Comments
Post a Comment