• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

php and ajax problem

Ranch Hand
Posts: 42
Postgres Database Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ;)
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Creativity is allowing yourself to make mistakes; art is knowing which ones to keep. Keep this tiny ad:
a bit of art, as a gift, the permaculture playing cards
    Bookmark Topic Watch Topic
  • New Topic