/    Sign up×
Community /Pin to ProfileBookmark

compare xmlhttp.responseText

hi everybody im new to javascript i like to access a PHP file do some work and then if all is successful return the response text update the div innerhtml compare div content with xmlhttp.responseText

[code]
if(xmlHttp.readyState==4){
var result = xmlhttp.responseText;
var tagcon = document.getElementById(“iddiv”).value;
if (result == tagcon)
document.getElementById(divid).innerHTML=xmlHttp.responseText;
[/code]

thanks

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@KorMay 05.2010 — You should check the [B]status[/B] of the AJAX object as well
<i>
</i>if(xmlHttp.readyState==4){
[COLOR="Blue"]if(xmlHttp.[B]status[/B]==200){[/COLOR]
var result = xmlhttp.responseText;
var tagcon = document.getElementById("iddiv").value;
if (result == tagcon){
document.getElementById(divid).innerHTML=xmlHttp.responseText;
}
[COLOR="Blue"]}[/COLOR]
}
Copy linkTweet thisAlerts:
@mardinoauthorMay 05.2010 — thanks for replaying what i mean is how do i put the xmlhttpresponseText in a variable declare it globally and compare it with the next xmlhttpresponsetext and if both matched then do something

if (xmlhttp1 == xmlhttp2)

alert("")
Copy linkTweet thisAlerts:
@KorMay 05.2010 — what i mean is how do i put the xmlhttpresponseText in a variable declare it globally and compare it with the next xmlhttpresponsetext[/QUOTE]

And what prevents you to do that? Make your variable global and compare it with the response text. Where is the problem, after all?
Copy linkTweet thisAlerts:
@mardinoauthorMay 05.2010 — well here again my problem is dont know much about ajax i what im saying is

store xmlhttpresponseText in a variable and hold it i dont what to lose it when the page refresh but when the page refresh i want to compare the variable we hold it and compare it with xmlhttpresponseText when the page refreshed

var xmlhttp1 = xmlhttpresponseText i dont want to this variable change when the page refreshed

var xmlhttp2 = xmlhttpresponseText

if (xmlhttp1 == xmlhttp2)

alert("")
Copy linkTweet thisAlerts:
@KorMay 05.2010 —  i dont want to this variable change when the page refreshed [/QUOTE]
Then call that function [B]onload[/B]
Copy linkTweet thisAlerts:
@mardinoauthorMay 05.2010 — you have no ideal what im talking about
Copy linkTweet thisAlerts:
@KorMay 05.2010 — you have no ideal what im talking about[/QUOTE]
Me neither about what [I]you[/I] are talking about. Post by post you slip into a confounded swamp. You are very confusing regarding your aim, programming language, syntax and possibilities.

Can you re-form your problem once again, with patience and with high clarity, please?
×

Success!

Help @mardino 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.24,
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,
)...