I have two problems with the same php/ajax solution. The first is a weird problem. Or maybe I'm just missing something. i have a php page that displays data from a database. so let's say when it loads the first time, "myavalue" = 1.
On the same page i have a refresh button that triggers an ajax function to get the latest data from the database. If I change the value in the database from 1 to 2, and then use this button, the page does display 2. however, when i do a view source on the page, it shows the value 1 instead of 2. Why is this? i've tried it both in IE 9 and also in fire fox.
The second issue may be related... the problem is with the same page that I mentioned above. When the refresh button is clicked, i'm actually generating html in my controller and then having my view display it. what i'm noticing is that in the view source, the html is missing a class name that i assign to my table cells. However, in my console, i can see that the html that the controller is generating does infact include the proper class names. Here's what the console is showing:
<tr><td>10.14.193.0/27</td><td>Vancouver Island</td><td class='deadclient'>2012-06-13 12:12:12</td></tr>
And here's what the view source is showing:
<tr>
<td>10.14.193.0/27</td>
<td>Vancouver Island</td>
<td>2012-06-13 12:12:12</td>
</tr>
I have two problems with the same php/ajax solution. The first is a weird problem. Or maybe I'm just missing something. i have a php page that displays data from a database. so let's say when it loads the first time, "myavalue" = 1.
On the same page i have a refresh button that triggers an ajax function to get the latest data from the database. If I change the value in the database from 1 to 2, and then use this button, the page does display 2. however, when i do a view source on the page, it shows the value 1 instead of 2. Why is this? i've tried it both in IE 9 and also in fire fox.
The second issue may be related... the problem is with the same page that I mentioned above. When the refresh button is clicked, i'm actually generating html in my controller and then having my view display it. what i'm noticing is that in the view source, the html is missing a class name that i assign to my table cells. However, in my console, i can see that the html that the controller is generating does infact include the proper class names. Here's what the console is showing:
<tr><td>10.14.193.0/27</td><td>Vancouver Island</td><td class='deadclient'>2012-06-13 12:12:12</td></tr>
And here's what the view source is showing:
<tr>
<td>10.14.193.0/27</td>
<td>Vancouver Island</td>
<td>2012-06-13 12:12:12</td>
</tr>
Share
Improve this question
edited Feb 7, 2014 at 0:59
John Conde
220k99 gold badges462 silver badges501 bronze badges
asked Jun 13, 2012 at 19:57
dotdot
15.7k43 gold badges128 silver badges264 bronze badges
3 Answers
Reset to default 6The view source does not show the effects of JavaScript on the original source code. You'll need to view the altered source code through a tool like Firebug or chrome's dev tools to see the effects of any JavaScript you are using.
"View Source" is better worded as "View Original Source" (and I believe it is in some browsers). It is the source of the page before JavaScript had any say on the matter.
To view real-time source, use whatever Developer Tools your browser has. IE has the F12 Tools, Chrome has the Inspector, and Firefox recently added the Web Developer.
The point is that there is a difference between "View Source" and what is actually on the page. It's like trying to look at the source of a stream by looking at where it meets the ocean.
The view-source option of Firefox will do another request to the page to get the HTML response. To confirm what I'm saying, you can try a page with a form, it'll ask you if you want to re-send the data twice.
What you want is something like Chrome built-in developper tool, you will see the source in real-time, as it is modified by Javascript and even make change to the markup and see it live.
Have fun, your problem is not a real problem :]