/    Sign up×
Community /Pin to ProfileBookmark

Hi i’m trying to make a website with ajax. This is what i have:

[code=php]
//javascript
//AJAX
var XMLHttpRequestObject = false;

if (window.XMLHttpRequest) {
XMLHttpRequestObject = new XMLHttpRequest();
} else if (window.ActiveXObject) {
XMLHttpRequestObject = new ActiveXObject(“Microsoft.XMLHTTP”);
}

function getData(dataSource, divID){
if(XMLHttpRequestObject) {
var obj = document.getElementById(divID);
XMLHttpRequestObject.open(“GET”, dataSource);

XMLHttpRequestObject.onreadystatechange = function()
{
if (XMLHttpRequestObject.readyState == 4 &&
XMLHttpRequestObject.status == 200) {
obj.innerHTML = XMLHttpRequestObject.responseText;
}
}

XMLHttpRequestObject.send(null);
}
}
[/code]

when i call this:

[code=php]
getData(‘pages/menu.php’,’mainMenu’);
[/code]

the information that is output at the php page menu.php is shown in mijn DIV mainMenu works great….but what to do when i want to send information to multiple DIV’s so the file menu.php sends one part of information to my DIV mainMenu and another part of information to the DIV subMenu is this possible????

thanks in advance!!
Zeb

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@Sid3335Nov 28.2006 — is the div subMenu nested within the mainMenu?

if it is you can just generate the code for the submenu on the server side.

if it isn't you could just use a delimiter and echo back the two sections (main and sub).

so if you retreive:

CODE_FOR_MAIN--delimiter--CODE_FOR_SUB

then just split using the delimter, then update each div with the values (split array).
Copy linkTweet thisAlerts:
@zebdaagauthorNov 28.2006 — nope
Copy linkTweet thisAlerts:
@Sid3335Nov 28.2006 — split like this:

<i>
</i>update = response.split('--delimiter--');
mainMenu.innerHTML.innerHTML = update[0];
subMenu.innerHTML.innerHTML = update[1];
×

Success!

Help @zebdaag spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...