DeanWhitehouse Posted June 23, 2008 Share Posted June 23, 2008 I have just started to learn AJAX and i am making a chatroom the problem i am having is on how to pull data from the php file and display the data inside another page, and how to show current data, as it will continuosly be changing. Any one know how to do this, the most i have been able to do so far is display data inside a input field from a php file. Quote Link to comment https://forums.phpfreaks.com/topic/111567-ajax-to-always-pull-and-display-data/ Share on other sites More sharing options...
xtopolis Posted June 24, 2008 Share Posted June 24, 2008 <div id="myDiv"></div> document.getElementById('myDiv').innerHTML = XMLHttpRequestObject.responseText; innerHTML changes the entire content between the tags cited by the ID of the element. Quote Link to comment https://forums.phpfreaks.com/topic/111567-ajax-to-always-pull-and-display-data/#findComment-572867 Share on other sites More sharing options...
DeanWhitehouse Posted June 24, 2008 Author Share Posted June 24, 2008 will this always be updating though?? Or will they have to refresh the page? Quote Link to comment https://forums.phpfreaks.com/topic/111567-ajax-to-always-pull-and-display-data/#findComment-573156 Share on other sites More sharing options...
figmented Posted June 24, 2008 Share Posted June 24, 2008 Use the "innerHTML" property for DIV, SPAN, and similar layout elements. Use the "value" property for INPUT, TEXTAREA, and similar form elements. Use events to specify when AJAX should be requested. The event verbiage "onClick", "onLoad", and "onMouseOver" is very easy to understand. I've created a simple Base64 encoder and attached it to this post. You can see that when a user enters a string and clicks the "encode" button, the encoded string is displayed. I used the "onClick" attribute to make this work. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/111567-ajax-to-always-pull-and-display-data/#findComment-573412 Share on other sites More sharing options...
DeanWhitehouse Posted June 24, 2008 Author Share Posted June 24, 2008 Ok, thanks for the help and the example code. I have decided to go with an open source chat room. Ajax Chat. Quote Link to comment https://forums.phpfreaks.com/topic/111567-ajax-to-always-pull-and-display-data/#findComment-573418 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.