![]() |
refresing page without reload using ajax and php
I want to make a comment for visitors where they can add comments and it will get updated without refreshing .
I have gone though a lot of tutorial but they dont tell how to code the .js file or .php file Please help. |
what is hard about it?
Making the request Code:
var req;SendData("Eric","Foo Bar Candy"); Getting the request back you set the innerHTML with the responseText where you want it to show up. Code:
function processReqChange() {On the server You handle the Post like any other form submission and spit out the HTML that you want to show up. (I know almost zippo about php) Code:
print "Your elephant's name is: " . $_POST['name']; |
CAN U PLEASE EXPLAIN WHICH FILE IS .js and which one is php., as i am new to this...
|
SendData() and processReqChange() are the javascript codes, they can be put in a .js file and the last code which is labeled "On the server" is the php.
|
instead of
PHP Code:
PHP Code:
|
hey i got the same problem but i cant fix it.. i tried the above but it dont help
i got several files.. projecten.php, projecten.incl.php and selectuser.js and some more but u dont need them for the problem true AJAX i get a variable "q" (in projecten.php and he shows every think i want to see that works great now i want from another file to call the ajax (go to a new page with a link) and i send a POST or GET with it.. but then does the ajax dont pick it up.. does anybody got a solution here for? i now way it wound work. i call the file projecten.php with a variable in GET but i need to call selectuser.js with a var.. how can i do that with a link.. or somethink like that..? i hope u get the problem.. else just ask i will post the code below.. i hope u can find what i need to change selectuser.js Code:
var xmlHttpCode:
<?php $project = $_GET['q']; ?>Code:
<!doctype html public "-//W3C//DTD HTML 4.0 //EN"> |
Look how I handle the response, you NEED to check for the status code. Open up Firefox and load Firebug [http://getfirebug.com/]. Watch the XMLHttpRequest.
Eric |
Quote:
i did find out that i need to get the GET variable to the .js file.. if that can be done i can change the variable and the ajax will work:) so i got projecten.php?projecten=testproject now i need that variable to the selectuser.js file without doing anythink ( so i want to be compleetly automatic) do u now how i can do that? |
Call the function with window.onload?
Eric |
i tried somethings with it but nothing worked, i looked on the web but what i saw from it i dont think that is the think i need.
it could be that my code was to buggy it that way it dont worked.. but im afraid it is not what im looking for |
I am not sure what you are talking about exactly.. am taking a guess that you want to call the function when the page load to load what ever is selected?
The JavaScript would look something like: Code:
window.onload = function() |
Quote:
now i got some links on another page. when i press the link i want to go to http://localhost/planning/index.php?...&project=OCV27 the page projecten (that works) and then i want to activate the ajax (automatic) and that the variable project into the ajax get so that ajax maken the stuff visable. i will try to set the page online so u can see it by ure self (uhm i cant do it now .. i will try it again to night. i hope u get the problem now.. else just ask:) thnx for the time u try to help me ------------------------- update i fixed the problem $proj = $_GET['project']; if( isset( $proj ) ) { echo"<script type=\"text/javascript\">showUser('" . $proj . "');</script>"; } was the code i needed:) |
Relaod page for every user
Hi
How can we refresh a page for every user same like http://www.telebid.com/ using ajax and php Anyone can help me with code /Sample Thanks Davinder |
Quote:
|
can you tell me how can i
Quote:
Plz help me . i want to refresh page using ajax periodically Thanks |
| All times are GMT +1. The time now is 02:46 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.