Meaningless Drivel is fun!*
The moose likes PHP and the fly likes php and ajax problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Languages » PHP
Bookmark "php and ajax problem" Watch "php and ajax problem" New topic
Author

php and ajax problem

Alexandru Gifei
Ranch Hand

Joined: May 19, 2012
Posts: 40

Hello. I have the following script where i receive a message from a http client and return it as a string.


In this last script i am using Ajax to get the $lastLine string from status.php, and display the content in it's div containter, but i want to split $lastLine by spaces, into an array, and use ajax to populate the page with the values of this array because i want to use them later to build a html table. So the question is HOW can i use ajax to load the data from the array into the variables into $btStatus, $maxTemp, $minTemp, $currentTemp, and use them later? or HOW can i get the string that is displayed in the div container and use it later?

Edit: I came up with a solution, to build the html table in status.php and echo it with ajax in the div container. But im looking for a better solution ;)


Life is not measured by the number of breaths we take, but by the moments that take our breath away.
Clivant Yeo
Ranch Hand

Joined: May 22, 2004
Posts: 124
I guess I will just let status.php output the required data without any formatting, which could be JSON or csv format.

Then I will use jQuery/javascript to load the data into some variables which I will manipulate and do the formatting.

This is because, the visual aspect of an application tends to change more then server side counterpart. By pushing the formatting job to the javascript side, you will only need to make any visual changes in one file. But if you were to let your server end output the visual information, you will need to change the data in more places.

But of course to cater to cases in which Javascript is disabled, I will have another PHP file which will provide for the visual aspect. And I will group the file under a same folder as index.php, so that when I need to change the visual part, I will not need to look too far.

Just my 2 cents though.


Clivant Yeo
My Personal Website
 
 
subject: php and ajax problem
 
Similar Threads
expand and collapse buttons
Ajax and post messages
Bash Script Help
"un-reading" a line
Algorithm-Problem: Manipulate a line that depends on the next line