Welcome to WebmasterWorld Guest from 54.234.153.186

Forum Moderators: open

Message Too Old, No Replies

onclick import a file using ajax javascript php

import a file using ajax javascript php

     

evo81

10:29 pm on Aug 15, 2006 (gmt 0)

5+ Year Member



Hello,

Okay I'm working on an events page and there is a list of events, I want to have a button next to each event that you can click to see more details for each each event. I dont wanna have page reloads so can anyone think how to do this?

Any help much appreciated

Thanks

garann

7:23 pm on Aug 17, 2006 (gmt 0)

10+ Year Member



Should be pretty basic. Your button's onclick just needs to send the ID of the event to a Javascript function, and you need a PHP file that can take that ID and return the info.


var http;
function getEvent(eventID) {
if (navigator.appName == "Microsoft Internet Explorer") {
http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
http = new XMLHttpRequest();
}
if (http) {
http.open("get", "yourpage.php?event="+eventID);
http.onreadystatechange = handleResponse;
http.send(null);
}
}
function handleResponse() {
if (http.readyState == 4) {
var response = http.responseText;
if (response && response!= "")
document.getElementById("someContainer").innerHTML = response;
}

}

Hope it helps. :)

evo81

9:35 pm on Aug 23, 2006 (gmt 0)

5+ Year Member



Thanks for taking the time to reply garann, much appreciated
 

Featured Threads

Hot Threads This Week

Hot Threads This Month