/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] ajax remote call question

I have a simple ajax RPC to execute requests on an external php script.

My question is:

My goal is to have a div pop up ONLY if a condition is true. if a condition is false, I don’t want anything to happen.

I know how to do this in several languages, but my ajax learning curve isn’t at the top of the hill yet.

can someone point me to a good tutorial for this and/or give me an example to look at?

Thanks.

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@jeremuMay 15.2008 — If you know the basic syntax of AJAX you can just put a popup function in the on ready state = 4.

Let me know if you need more help.

If you had some source code it would help.
Copy linkTweet thisAlerts:
@jamied66authorMay 15.2008 — I'm getting more comfortable with the syntax, to be sure.

here's my function to handle responses from the external file (painfully simple)

[CODE]
function handleResponse() {
if(http.readyState == 4){
document.getElementById("cu_info").innerHTML = http.responseText;
}
}
[/CODE]


my question is, how do i get nothing to happen if the query i'm executing returns no results. http.readyState will still = 4. I'm guessing I'll have to tell the external script to do something, I'm just at a loss for what.
Copy linkTweet thisAlerts:
@jeremuMay 15.2008 — [CODE]
function handleResponse() {
if(http.readyState == 4){
document.getElementById("cu_info").innerHTML = http.responseText;

if(http.responseText != '' )
//do something
}
}
[/CODE]
Copy linkTweet thisAlerts:
@jamied66authorMay 15.2008 — haha.

i thought to myself

"it can't be that simple..." before posting this. Thanks a lot!
Copy linkTweet thisAlerts:
@jeremuMay 15.2008 — hehe.

AJAX will do that to you.

I'm glad I could help.

Just watch out for those pop-up blockers.
×

Success!

Help @jamied66 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.19,
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,
)...