Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

onclick import a file using ajax javascript php

import a file using ajax javascript php



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

5+ Year Member


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



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;
function handleResponse() {
if (http.readyState == 4) {
var response = http.responseText;
if (response && response!= "")
document.getElementById("someContainer").innerHTML = response;


Hope it helps. :)


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