Jump to content

Recommended Posts

Hello

 

Okay let me explain throughly.

say I have a index.php page

 

which has ajax JS (note THIS IS NOT A AJAX PROBLEM!, it's PHP)

 

in the index I have.

 

<?php
session_start();
ini_set('display_errors', '1'); //show errors.
//include_once 'functions.php';

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript" src="js/ajax.js"></script>
<script type="text/javascript">
    function updateUI(str) {
            var ajaxObj = new XMLHttp();
            var url = 'ajax.php';
            var method = 'POST';
            var params = 'page='+str;
            makeRequest(ajaxObj, method, url, params, 'maincontent');
            ajaxObj = null;
    }
</script>
</head>

<body>
<table border="1" align="center" width="440" height="330">
  <tr>
    <th scope="col">
    <form name="UI" id="UI" action="" onsubmit="return false;">
    <div id="maincontent">
        <?php
    include 'ajax/login.php';
?>
    </div>
    </form>
    </th>
  </tr>
</table>
</body>
</html>

 

ajax.php is simply the data outputter.

 

<?php
$page = (isset($_POST['page']) ? $_POST['page'] : '');
if ($page == "login") {
    include 'ajax/login.php';
} elseif ($page == "dologin") {
    include 'ajax/dologin.php';
} elseif ($page == "startingstats") {
    include 'ajax/startingstats.php';
} elseif ($page == "rankings") {
    include 'ajax/rankings.php';
} elseif ($page == "updates") {
    include 'ajax/updates.php';
} elseif ($page == "howto") {
    include 'ajax/howto.php';
} else {
    include 'ajax/login.php';
}
?>

 

 

now the ajax folder has all the scripts that get outputted..

 

lets say the login.php page in ajax folder for now

      <script type="text/javascript"> 
        <!--
        var ubool = 0;
        var pbool = 0;
        var jsuser = '';
        var jspw = '';

        function userCheck(user)
        {
          jsuser = user;
          ubool = (user.length > 0) ? 1 : 0;
          if(ubool && pbool)
            document.getElementById("login").style.visibility = "visible";
          else            
            document.getElementById("login").style.visibility = "hidden";
        }
        
        function pwCheck(pass)
        {
          jspw = pass;
          pbool = (pass.length > 0) ? 1 : 0;
          if(ubool && pbool)
            document.getElementById("login").style.visibility = "visible";
          else            
            document.getElementById("login").style.visibility = "hidden";
        }
        
        function doLogin() {
            var ajaxObj = new XMLHttp();
            var url = 'ajax.php';
            var method = 'POST';    
            var params = 'page=dologin&user='+jsuser+'&pw='+jspw;
            makeRequest(ajaxObj, method, url, params, 'maincontent');
            ajaxObj = null;
        }
        //-->
      </script>
      
      <div style="position: fixed; top: 222px; margin-left: 120px; color: white;">Welcome Kongregate Name</div>
      <div style="position: fixed; top: 252px; margin-left: 2px; color: white;">Hero Name:</div>
      <div style="position: fixed; top: 282px; margin-left: 2px; color: white;">Password:</div>
      <div style="position: fixed; top: 252px; margin-left: 90px;"><input type="text" name="user" id="user" size="12" maxlength="20" value="" onInput="javascript:userCheck(this.value)" onpropertychange="javascript:userCheck(this.value)" /></div>
      <div style="position: fixed; top: 282px; margin-left: 90px;"><input type="text" name="pw" id="pw" size="12" maxlength="20" value="" onInput="javascript:pwCheck(this.value)"  onpropertychange="javascript:pwCheck(this.value)" /></div>
      <div id="login" style="position: fixed; top: 252px; margin-left: 210px; visibility: hidden;"><input type="image" src="images/quest.jpg" width="96" height="64" onClick="javascript:doLogin()" /></div>    
      <div style="position: fixed; top: 252px; margin-left: 334px;"><input type="submit" name="rankings" value="Ranking List" onClick="javascript:updateUI('rankings')"></div>
      <div style="position: fixed; top: 282px; margin-left: 357px;""><input type="submit" name="updates" value="Updates" onClick="javascript:updateUI('updates')"></div>
      <div style="position: fixed; top: 312px; margin-left: 300px;"><input type="submit" name="howto" value="How to get started" onClick="javascript:updateUI('howto')"></div>  
      <img src="images/splash.jpg" width="440" height="330" />

 

yes it has no forms in the page above so javascript shouldn't function right?

Wrong look at index.php it has a <form> wrapper that wraps the <div> which gets updated by the ajax.php outputter that outputs ajax folder pages.

 

Note okay that works.. the javascript functions on it all wonderfully.

 

Now in this ajax/login.php thats loaded if you login with lets say pkedpker it checks it using index.php's javascript ajax call to ajax.php which calls dologin.php page in ajax folder.

 

ajax/dologin.php is simply

 

<?php
//if(isset($_POST['user']) &&isset($_POST['pw'])) {
//	echo "user and password both set";
if($_POST['user'] == "pkedpker") { //and IS ALSO NEWBIE! STATING SCREEN COMES NEXT
?>
<div style="background-color: #000000; color: #FFFFFF; font-weight: bold; width: 440px; height: 330px;">
A young hero arises from the plebium masses!
<div style="position: fixed; top: 312px; margin-left: 300px;"><input type="submit" name="login" value="Done" onclick="javascript:updateUI('startingstats')"></div>
</div>
<?php
}
elseif($_POST['user'] != "pkedpker") {
?>
<div style="background-color: #000000; color: #FFFFFF; font-weight: bold; width: 440px; height: 330px;">
Error: Hero Not Found [ <?php echo $_POST['user'] ?> ]
<div style="position: fixed; top: 312px; margin-left: 300px;"><input type="submit" name="login" value="Done" onclick="javascript:updateUI('login')"></div>
</div>
<?php
} else {
?>
<div style="background-color: #000000; color: #FFFFFF; font-weight: bold; width: 440px; height: 330px;">
Error/Hack Attempt?: Username or password were found to be empty!
<div style="position: fixed; top: 312px; margin-left: 300px;"><input type="submit" name="login" value="Done" onclick="javascript:updateUI('login')"></div>
</div>
<?php } ?>

 

Nothing important just a few little tests I've setup.. the test that is interesting me is the

'A young hero arises'

which has a ajax call to index.php that calls ajax.php which then includes a page from ajax folder called startingstats

 

This is the ajax/startingstats.php code

 

      <script type="text/javascript"> 
        <!--
        var buildPts = 20;
        
        function buildPointsCheck(skill, direction, isMoney)
        {
          if(isMoney === 0) {
            if(direction == 1 && buildPts > 0) {
              buildPts--;
              skill.value++;
            } else if(direction === 0 && skill.value > 0) {
              buildPts++;
              skill.value--;
            }
          } else {
            var curMoney = (skill.value >= 25) ? skill.value / 25 : 0;
            if(direction == 1 && buildPts > 0) {
              buildPts--;
              curMoney++;
            } else if(direction === 0 && curMoney > 0) {
              buildPts++;
              curMoney--;
            }
            skill.value = (curMoney * 25);
          }
          if(buildPts === 0) {
            document.getElementById("login").style.visibility = "visible";
          } else {
            document.getElementById("login").style.visibility = "hidden";
          }

          document.getElementById("buildpoints").value = buildPts;
        }
        
        function buildOptionsCheck(buildOption) 
        {
          if(buildOption.checked) {
            if(buildOption.name == "wizard" && buildPts >= 9) {
              buildPts-=9;
            } else if(buildOption.name == "trader" && buildPts >= 10) {
              buildPts-=10;
            } else if(buildOption.name == "warrior" && buildPts >=  {
              buildPts-=8;
            } else if(buildOption.name == "sage" && buildPts >= 12) {
              buildPts-=12;
            } else {
              buildOption.checked = false;
            }
          } else {
            if(buildOption.name == "wizard") {
              buildPts+=9;
            } else if(buildOption.name == "trader") {
              buildPts+=10;
            } else if(buildOption.name == "warrior") {
              buildPts+=8;
            } else if(buildOption.name == "sage") {
              buildPts+=12;
            }
          }
          if(buildPts === 0) {
            document.getElementById("login").style.visibility = "visible";
          } else {
            document.getElementById("login").style.visibility = "hidden";
          }

          document.getElementById("buildpoints").value = buildPts;
        }
        
        function setStats() 
        {
            var ajaxObj = new XMLHttp();
            var url = 'ajax.php';
            var method = 'POST';    
            var params = 'page=startingstats&guts='+document.getElementByName("guts").value+'&wits='+document.getElementByName("wits").value+'&charm='+document.getElementByName("charm").value+'&money='+document.getElementByName("money").value+'&wizard='+document.getElementByName("wizard").value+'&trader='+document.getElementByName("trader").value+'&warrior='+document.getElementByName("warrior").value+'&sage='+document.getElementByName("sage").value;
            makeRequest(ajaxObj, method, url, params, 'maincontent');
            ajaxObj = null;
        }
        //-->
      </script>
<div style="background-color: #0000FF; color: #FFFFFF; font-weight: bold; width: 440px; height: 330px;">
  <table border="1" align="center">
    <th colspan="3"><span style="color: #00FF00; font-weight: bold;">stepansky</span></th>
    <tr>
    <td>
      <div align="center"><span style="color: #FFFF00; font-weight: bold;">Guts</span><br />
      <table>
      <tr>
        <td><input name="button" type="button" value="+" onClick="javascript:buildPointsCheck(this.form.guts, 1, 0)" style="font-size:7px;margin:0;padding:0;width:20px;height:13px;"></td> 
        <td rowspan=2><input type="text" name="guts" value="4" size="5"></td>
      </tr>
      <tr>
        <td><input name="button2" type="button" value="-" onClick="javascript:buildPointsCheck(this.form.guts, 0, 0)" style="font-size:7px;margin:0;padding:0;width:20px;height:13px;"></td>
      </tr>
      </table>    
      </div>  
    </td>
    <td>
      <div align="center"><span style="color: #FFFF00; font-weight: bold;">Wits</span><br />
      <table>
      <tr>
        <td><input name="button" type="button" value="+" onClick="javascript:buildPointsCheck(this.form.wits, 1, 0)"  style="font-size:7px;margin:0;padding:0;width:20px;height:13px;"></td> 
        <td rowspan=2><input type="text" name="wits" value="4" size="5"></td>
      </tr>
      <tr>
        <td><input name="button2" type="button" value="-" onClick="javascript:buildPointsCheck(this.form.wits, 0, 0)" style="font-size:7px;margin:0;padding:0;width:20px;height:13px;"></td>
      </tr>
      </table>    
      </div>  
    </td>
    <td>    
      <div align="center"><span style="color: #FFFF00; font-weight: bold;">Charm</span><br />
      <table>
      <tr>
        <td><input name="button" type="button" value="+" onClick="javascript:buildPointsCheck(this.form.charm, 1, 0)" style="font-size:7px;margin:0;padding:0;width:20px;height:13px;"></td> 
        <td rowspan=2><input type="text" name="charm" value="4" size="5"></td>
      </tr>
      <tr>
        <td><input name="button2" type="button" value="-" onClick="javascript:buildPointsCheck(this.form.charm, 0, 0)" style="font-size:7px;margin:0;padding:0;width:20px;height:13px;"></td>
      </tr>
      </table>    
      </div>  
    </td>
    </tr>
    <tr>
    <td colspan="2">
      <div align="center"><span style="color: #FFFF00; font-weight: bold;">Options</span>
        <table width="100%"  border="0">
        <tr>
          <td><input type="checkbox" name="wizard" value="" onClick="javascript:buildOptionsCheck(this.form.wizard)">
          Wizard 9p</td>
          <td><input type="checkbox" name="trader" value="" onClick="javascript:buildOptionsCheck(this.form.trader)">
          Trader 10p</td>
        </tr>
        <tr>
          <td><input type="checkbox" name="warrior" value="" onClick="javascript:buildOptionsCheck(this.form.warrior)">
          Warrior 8p</td>
          <td><input type="checkbox" name="sage" value="" onClick="javascript:buildOptionsCheck(this.form.sage)">
          Sage 12p</td>
        </tr>
        </table>
      </div>
      </td>
    <td>
      <div align="center"><span style="color: #FFFF00; font-weight: bold;">Money(1p=$25)</span><br />
      <table>
      <tr>
        <td><input name="button" type="button" value="+" onClick="javascript:buildPointsCheck(this.form.money, 1, 1)"  style="font-size:7px;margin:0;padding:0;width:20px;height:13px;"></td> 
        <td rowspan=2><input type="text" name="money" value="25" size="7"></td>
      </tr>
      <tr>
        <td><input name="button2" type="button" value="-" onClick="javascript:buildPointsCheck(this.form.money, 0, 1)"  style="font-size:7px;margin:0;padding:0;width:20px;height:13px;"></td>
      </tr>
      </table>    
      </div>
    </td>
    </tr>
    <tr>
    <td>
      <div align="center"><span style="color: #FFFF00; font-weight: bold;">Build Points left</span><br />
        <input type="text" id="buildpoints" name="buildpoints" value="20" size="5">
      </div>
    </td>
    <td>
      <div id="login" style="visibility: hidden;">
        <input type="image" src="images/quest.jpg" width="96" height="64" onClick="javascript:setStats()" />
      </div>
    </td>
    <td>
      <center>
        <input type="image" onClick="javascript:updateUI('login')" src="images/exit.jpg" />
      </cener>
    </td>
    </tr>
  </table>
</div>

 

 

Now just including ajax/startingstats.php in index.php instead ajax/login.php

IT FUNCTIONS perfectly!.

 

Now if I let it all run normal using dologin.php to make the startingstats.php page load up which it does.. the javascript doesn't function tell me why? can someone please tell me why  :'(  :'(

 

Thank you!

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/197785-why-php-makes-javascript-fail/
Share on other sites

Couple things.

 

If login.php is being called instead of the page you want, I'm going to assume it's because  of this area right here.

 

$page = (isset($_POST['page']) ? $_POST['page'] : '');
if ($page == "login") {
//Continue logic...at the bottom you have 
} else {
    include 'ajax/login.php';
}

 

 

Basically you're saying if $_POST['page'] isn't set, then include login.php

 

I would look at what variable you're passing your controller (for lack of a better word).

 

For what it's worth (and I'm saying this to be constructive, not to be critical) your logic and flow is really really off kilter.  As your project grows, (and as your'e finding out) this is going to become more and more of a nightmare to maintain.

 

 

Honestly it will grow but I love the layout I have right now.. still doesn't explain to me why javascript doesn't work from 2nd page like

 

index.php -> ajax/login.php  - javascript works

index.php -> ajax/login.php -> ajax/dologin.php -> ajax/startingstats.php  -javascript doesn't work

 

Yes you may be thinking $page is probably static and has some old values or something? thats not the case and thats because statingstats.php is actually displayed perfectly in the flow it works.

 

I know it seems really bad coding like if you call ajax/dologin.php explicitly it will show rubbish because it shouldn't ever be called like that in the first place anyways thats not the problem anyways sorry and I know what you mean. But I'm trying to keep my mind free and everything organized like ajax output calls should all be in 1 folder this is best organizing my brain can handle.

PHP won't make javascript fail. HTML output may cause your javascript to not work.

 

So if you are having javascript issues, you should post the HTML output. After finding the problem there, it will be easier to figure out what PHP code is creating the output that is causing the javascript to fail.

Thats the thing.. nothing is wrong with the HTML Output as it functions perfectly! I did Inspect Elements in Google Chrome and copy/pasted the current source code loaded.. saved it as a html file.. put it in webserver.. ran it.. WORKS PERFECTLY!!

 

So it could ONLY be PHP related.

 

I mean you want to to sniff my network packets to piece together the output and see that it will work? but when it's normally loaded by PHP it doesn't.. because thats what will happen.

 

I'm not making this up either there is a bug with PHP or something unholy force preventing me from completing this product.. maybe god himself!

 

Thats the code PHP generated.. when I run it normally javascript fails.. states functions are undefined.. and don't exist.. and yes if I try to press any buttons while in Inspection view.. the javascript gets overwritten with login.php page wtf? but I don't see the login.php page neither did I do any php requests to get login.php to load on top..

 

but saving the page it loaded and replying it works perfectly!

 

<html><head>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript" src="js/ajax.js"></script>
<script type="text/javascript">
    function updateUI(str) {
            var ajaxObj = new XMLHttp();
            var url = 'ajax.php';
            var method = 'POST';
            var params = 'page='+str;
            makeRequest(ajaxObj, method, url, params, 'maincontent');
            ajaxObj = null;
    }
</script>
</head><body>
<table border="1" align="center" width="440" height="330">
  <tbody><tr>
    <th scope="col">
    <form name="UI" id="UI" action="" onsubmit="return false;">
    <div id="maincontent">      <script type="text/javascript"> 
        <!--
        var buildPts = 20;
        
        function buildPointsCheck(skill, direction, isMoney)
        {
          if(isMoney === 0) {
            if(direction == 1 && buildPts > 0) {
              buildPts--;
              skill.value++;
            } else if(direction === 0 && skill.value > 0) {
              buildPts++;
              skill.value--;
            }
          } else {
            var curMoney = (skill.value >= 25) ? skill.value / 25 : 0;
            if(direction == 1 && buildPts > 0) {
              buildPts--;
              curMoney++;
            } else if(direction === 0 && curMoney > 0) {
              buildPts++;
              curMoney--;
            }
            skill.value = (curMoney * 25);
          }
          if(buildPts === 0) {
            document.getElementById("login").style.visibility = "visible";
          } else {
            document.getElementById("login").style.visibility = "hidden";
          }

          document.getElementById("buildpoints").value = buildPts;
        }
        
        function buildOptionsCheck(buildOption) 
        {
          if(buildOption.checked) {
            if(buildOption.name == "wizard" && buildPts >= 9) {
              buildPts-=9;
            } else if(buildOption.name == "trader" && buildPts >= 10) {
              buildPts-=10;
            } else if(buildOption.name == "warrior" && buildPts >=  {
              buildPts-=8;
            } else if(buildOption.name == "sage" && buildPts >= 12) {
              buildPts-=12;
            } else {
              buildOption.checked = false;
            }
          } else {
            if(buildOption.name == "wizard") {
              buildPts+=9;
            } else if(buildOption.name == "trader") {
              buildPts+=10;
            } else if(buildOption.name == "warrior") {
              buildPts+=8;
            } else if(buildOption.name == "sage") {
              buildPts+=12;
            }
          }
          if(buildPts === 0) {
            document.getElementById("login").style.visibility = "visible";
          } else {
            document.getElementById("login").style.visibility = "hidden";
          }

          document.getElementById("buildpoints").value = buildPts;
        }
        
        function setStats() 
        {
            var ajaxObj = new XMLHttp();
            var url = 'ajax.php';
            var method = 'POST';    
            var params = 'page=startingstats&guts='+document.getElementByName("guts").value+'&wits='+document.getElementByName("wits").value+'&charm='+document.getElementByName("charm").value+'&money='+document.getElementByName("money").value+'&wizard='+document.getElementByName("wizard").value+'&trader='+document.getElementByName("trader").value+'&warrior='+document.getElementByName("warrior").value+'&sage='+document.getElementByName("sage").value;
            makeRequest(ajaxObj, method, url, params, 'maincontent');
            ajaxObj = null;
        }
        //-->
      </script>

  <table border="1" align="center" style="background-color: #0000FF; color: #FFFFFF; font-weight: bold; width: 440px; height: 330px;">
    <tbody><tr><th colspan="3"><span style="color: #00FF00; font-weight: bold;">stepansky</span></th>
    </tr><tr>
    <td>
      <div align="center"><span style="color: #FFFF00; font-weight: bold;">Guts</span><br>
      <table>
      <tbody><tr>
        <td><input name="button" type="button" value="+" onclick="javascript:buildPointsCheck(this.form.guts, 1, 0)" style="font-size:7px;margin:0;padding:0;width:20px;height:13px;"></td> 
        <td rowspan="2"><input type="text" name="guts" value="4" size="5"></td>
      </tr>
      <tr>
        <td><input name="button2" type="button" value="-" onclick="javascript:buildPointsCheck(this.form.guts, 0, 0)" style="font-size:7px;margin:0;padding:0;width:20px;height:13px;"></td>
      </tr>
      </tbody></table>    
      </div>  
    </td>
    <td>
      <div align="center"><span style="color: #FFFF00; font-weight: bold;">Wits</span><br>
      <table>
      <tbody><tr>
        <td><input name="button" type="button" value="+" onclick="javascript:buildPointsCheck(this.form.wits, 1, 0)" style="font-size:7px;margin:0;padding:0;width:20px;height:13px;"></td> 
        <td rowspan="2"><input type="text" name="wits" value="4" size="5"></td>
      </tr>
      <tr>
        <td><input name="button2" type="button" value="-" onclick="javascript:buildPointsCheck(this.form.wits, 0, 0)" style="font-size:7px;margin:0;padding:0;width:20px;height:13px;"></td>
      </tr>
      </tbody></table>    
      </div>  
    </td>
    <td>    
      <div align="center"><span style="color: #FFFF00; font-weight: bold;">Charm</span><br>
      <table>
      <tbody><tr>
        <td><input name="button" type="button" value="+" onclick="javascript:buildPointsCheck(this.form.charm, 1, 0)" style="font-size:7px;margin:0;padding:0;width:20px;height:13px;"></td> 
        <td rowspan="2"><input type="text" name="charm" value="4" size="5"></td>
      </tr>
      <tr>
        <td><input name="button2" type="button" value="-" onclick="javascript:buildPointsCheck(this.form.charm, 0, 0)" style="font-size:7px;margin:0;padding:0;width:20px;height:13px;"></td>
      </tr>
      </tbody></table>    
      </div>  
    </td>
    </tr>
    <tr>
    <td colspan="2">
      <div align="center"><span style="color: #FFFF00; font-weight: bold;">Options</span>
        <table width="100%" border="0">
        <tbody><tr>
          <td><input type="checkbox" name="wizard" value="" onclick="javascript:buildOptionsCheck(this.form.wizard)">
          Wizard 9p</td>
          <td><input type="checkbox" name="trader" value="" onclick="javascript:buildOptionsCheck(this.form.trader)">
          Trader 10p</td>
        </tr>
        <tr>
          <td><input type="checkbox" name="warrior" value="" onclick="javascript:buildOptionsCheck(this.form.warrior)">
          Warrior 8p</td>
          <td><input type="checkbox" name="sage" value="" onclick="javascript:buildOptionsCheck(this.form.sage)">
          Sage 12p</td>
        </tr>
        </tbody></table>
      </div>
      </td>
    <td>
      <div align="center"><span style="color: #FFFF00; font-weight: bold;">Money(1p=$25)</span><br>
      <table>
      <tbody><tr>
        <td><input name="button" type="button" value="+" onclick="javascript:buildPointsCheck(this.form.money, 1, 1)" style="font-size:7px;margin:0;padding:0;width:20px;height:13px;"></td> 
        <td rowspan="2"><input type="text" name="money" value="25" size="7"></td>
      </tr>
      <tr>
        <td><input name="button2" type="button" value="-" onclick="javascript:buildPointsCheck(this.form.money, 0, 1)" style="font-size:7px;margin:0;padding:0;width:20px;height:13px;"></td>
      </tr>
      </tbody></table>    
      </div>
    </td>
    </tr>
    <tr>
    <td>
      <div align="center"><span style="color: #FFFF00; font-weight: bold;">Build Points left</span><br>
        <input type="text" id="buildpoints" name="buildpoints" value="20" size="5">
      </div>
    </td>
    <td>
      <div id="login" style="visibility: hidden;">
        <input type="image" src="images/quest.jpg" width="96" height="64" onclick="javascript:setStats()">
      </div>
    </td>
    <td>
      <center>
        <input type="image" onclick="javascript:updateUI('login')" src="images/exit.jpg">
      
    </center></td>
    </tr>
  </tbody></table>
</div>
    </form>
    </th>
  </tr>
</tbody></table>

</body></html>

 

Here is a packet sniff before

index.php?action=dlattach;topic=293833.0;attach=10506;image

 

Blah I won't be able to show any good packet sniffing but I'm just saying.. I left it sniffing when pressing the Done button and it seems 4 new RECV packets came in with the HTML output I peiced them all together they show like half the page but thats not the point because in Inspecter View I can see the whole page gets rendered perfectly I mean CODE so probably sniffer isn't working good either. But when I press any button in Stat Setting screen which has the flawed javascript no new packets came in so it may be clientside but still doesn't explain why if i save it and run it it works.. but like this it doesn't ... maybe some automatic clientside overwriting? if code is loaded like this can someone explain please

 

 

[attachment deleted by admin]

So it could ONLY be PHP related.

 

PHP is a processing language that runs on the server. Javascript is a processing language that runs on the client. Javascript only interacts with the output of a php script. Now, when PHP outputs flawed HTML (or XML or text), the Javascript can have troubles interacting with that.

 

Anyways in your HTML output that you printed up, the main problem I see is that the doctype has been printed out after the opening html and head tags, meaning that as far as browsers are concerned, you have no doctype. This often causes problems with javascript. Try changing your script so it outputs the doctype ahead of the opening HTML tag (with no whitespace before it).

@OP, Are you daft? the client won't even know what the hell is outputting it. (ASP, C, Ruby, JSP, CF, FF, PHP, LF, LNN, XMLDD); It will only see what is put out by the output buffer. The only possible problem is if PHP is parsing incorrect formatting, As it SHOULD BE the equivalent unless your coding or server is seriously mistaken, printed by ANSI C or MONO will not make a difference.

 

Why not do something useful and run a binary frame DIFFs on the PHP output vs Client JS? Why the on god's earth are you packet sniffing?

 

I'm not going to look at your problem, XMLHTTPReq's on client's ECMA's RT frames are not related to PHP.

doctype is at the beginning before <html> how its suppose to i've added it just to include everything maybe some deprecated function or javascript engine i dont know atleast like this it should use everything.

 

removing/adding doesn't help nothing..

 

umm so you guys can't solve it either?

 

seems the only possible solution is to include all javascript even that which won't be used more then once in a externel file.. it seems to be a bug with overwriting javascript..

 

do it once.. it still works.. do it twice then you have a problem

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.