Real Estate Forums
| Coding HTML, ASP, PHP, JAVA MYSQL and more. All coding questions should be asked here. |
![]() |
|
|
Thread Tools | Display Modes |
|
|||
|
I've got need for a page to keep checking the mysql db at a regular interval, basically as a way for the page to await my input to perform a task. I've been able to accomplish this by having a query performed and then, if the value is one type to simply refresh the same page (thus iniciating a new query) and check for an update again.
The problem is with the html page's constant flicker as it refreshes each time. Is there a way I could have just the db query refresh? And leave the html alone so it doesn't flicker? |
|
||||
|
hmm.. offhand i'd suggest using javascript and just tagging whatever you wanted to change to update that component..
__________________
Michael Krotchie - REALTOR® - Coldwell Banker Residential Brokerage, NRT LLC 6970 N. Oracle Road, Suite 100 Tucson, AZ 85704 520.404.4996 -- Mobile 520.544.4545 -- Office Tucson Real Estate | Tucson Real Estate Blog |
|
|||
|
Javascript is probably the way to go as Michael indicates. Look into doing an XMLHttpRequest to get the data. That way you can just refresh the part of the page you need and not the whole thing.
Do some research on AJAX. If that's too much for you there might be an easier way we could help identify if you give a more detailed description of the problem. |
|
|||
|
Well, maybe it is time I learn Javascript - or hunt for a script on a forum. I've been wanting to do that anyway.
I started researching XMLHttpRequest. That might be what I need. Refreshing "part of the page", just the mysql query, would solve the problem. I came across two intersting expressions too, in an article talking about building APIs _ You won't be able to please everyone _ Aim to displease everyone equally and _Code should read like prose I think I'll adapt the first, but will have to leave the second for the next lifetime :-) |
|
|||
|
Now I'm looking at Wikipedia's write up on AJAX. MMMMMMMMMMM --- input ----- mmmmmmmmmm
|
|
|||
|
ooh -- oooh
" In this tutorial, I will show you how to utilize AJAX to automatically poll your MySQL database for updates without your visitors needing to click anything. The final code will silently check for updates, and update the page if (and only if) new updates are found." http://www.codewalkers.com/c/a/Misce...AJAX-Tutorial/ Thanks all, looks like I'm on the right track |
|
|||
|
Also be careful your don't create too much load on your server if you have a lot of clients hitting the server. Success could kill you if your clients are pinging the server too frequently. Also, consider if there is no activity for a while you don't need to keep checking the server. One open browser could consume a lot of resources.
If you only expect a handful of users at first, don't worry about this. Just get it working first. Good luck. |
|
|||
|
I'm getting a bit bogged down here. I'm figuring out the ajax part but the javascript and the time refresh is getting me.
The first thing my little script needs to do is access the db constantly (I currently have it set at every ten seconds using meta refresh). I haven't seen any ajax scripts that do this but the following link with javascript made for ajax seems close. It is javascript though, and I can't even get started with it. Does it look like something that would query and return the values from a mysql db (using a php script ) ? http://www.servletsuite.com/servlets/ajaxtimertag.htm Part of its code is like this - <script language="JavaScript" src="cjajax.js"></script> <%@ taglib uri="taglib.tld" prefix="a" %> <a:AjaxTimer id="i1" url="newContent.jsp" timeout="10" handler="myHandler"> and it says about it "In this example your file newContent.jsp will be requested each 10 seconds." It sounds like if I replace newContent.jsp with getmysqldata.php the query would be done evry ten seconds, just what I need. I tried it but the syntax and such has me baffled. For instance, why does it place opening javascript tags in front of src="cjajax.js" and then close it immediately? And the webpage describing it doesn't say what src="cjajax.js" is supposed to be? Can someone please, get me started with this? Thanks |
|
|||
|
I think I am gaining -
Can someone tell me if the following code transition from javascript to php is properly done (or not even close)? if(xmlHttp.readyState==4) { xmlHttp.open("GET","getmymysqldata.php",true); xmlHttp.send(null); document.myForm.pause.value=xmlHttp.responseText; <? if($out_of_sequence_protect == 1){echo 'OOSP On '; |
![]() |
| Thread Tools | |
| Display Modes | |
|
|