ajax async:false can not work in google chrome 4.0

a place to get help

Moderator: 1.1 Moderators

ajax async:false can not work in google chrome 4.0

Postby ericlin328 on Tue Feb 02, 2010 9:58 am

i use mootools 1.1.2, code following as :
  1.  
  2.   url = 'index.php?option=com_fsite';
  3.   var req = new Ajax(url, {
  4.           mothed:'post',
  5.           async:false,
  6.           postBody:'&format=raw&task=getok&captcha_work='+josfm.captcha_work.value
  7.   }).request();
  8.   var ans = req.transport.responseText;
  9.  alert(ans);
  10.  


it can work in ff3.6 and ie7
but not work in google chrome 4.0, ans return undefined

there is any solution ? Thanks!!
ericlin328
 
Posts: 5
Joined: Tue Feb 02, 2010 9:45 am

Re: ajax async:false can not work in google chrome 4.0

Postby wowenkho on Tue Feb 02, 2010 11:45 am

you may wanna check your "mothed" option. :3
my sword is yours...
http://wowenkho.com

for those who want to talk with me quicker, add me on Yahoo! Messenger through my ID: michaelapeles
User avatar
wowenkho
mootools freak
 
Posts: 1146
Joined: Sat Aug 15, 2009 10:38 am
Location: Antipolo City, Philippines

Re: ajax async:false can not work in google chrome 4.0

Postby ericlin328 on Wed Feb 24, 2010 5:09 am

wowenkho wrote:you may wanna check your "mothed" option. :3



You can explain a bit?
Checks that an option?

why can not work in google chrome , ans return "undefined"
ericlin328
 
Posts: 5
Joined: Tue Feb 02, 2010 9:45 am

Re: ajax async:false can not work in google chrome 4.0

Postby dudeinmo on Wed Feb 24, 2010 6:05 pm

ericlin328 wrote:
wowenkho wrote:you may wanna check your "mothed" option. :3



You can explain a bit?
Checks that an option?

why can not work in google chrome , ans return "undefined"


What - wowenkho - was saying is that your code on line 4 should be :



you have :

  1. mothed:'post', // you spelled method wrong
"You have to be the change you want to see in the world" - Ghandi
Rob Crowder Designs ( My Site )
MooTools 1.11 Docs
MooTools 1.11 Demos
User avatar
dudeinmo
 
Posts: 10
Joined: Wed Jan 27, 2010 6:56 pm
Location: Sugar Creek, MO

Re: ajax async:false can not work in google chrome 4.0

Postby ericlin328 on Fri Feb 26, 2010 6:28 am

thx,dudeinmo
i am update this spelled mistake
  1.  
  2. url = 'index.php?option=com_fsite';
  3.   var req = new Ajax(url, {
  4.           method:'POST',
  5.           async:false,
  6.           data:'&format=raw&task=getok&captcha_work='+josfm.captcha_work.value
  7.   }).request();
  8.   var ans = req.transport.responseText;
  9.  alert(ans);
  10.  



but still return undefined on google chrome
ff==>ok
ie==>ok

there is any solution ?
Thank you!!
ericlin328
 
Posts: 5
Joined: Tue Feb 02, 2010 9:45 am

Re: ajax async:false can not work in google chrome 4.0

Postby wowenkho on Fri Feb 26, 2010 7:58 am

meh no wonder. you can't get it by alerting that way. you need to WAIT for the response to get back before you can actually alert and expect a value. i'm not sure what exactly but i know the Ajax class should have something like an onComplete or onSuccess event method. you can do your req.transport.responseText there.
my sword is yours...
http://wowenkho.com

for those who want to talk with me quicker, add me on Yahoo! Messenger through my ID: michaelapeles
User avatar
wowenkho
mootools freak
 
Posts: 1146
Joined: Sat Aug 15, 2009 10:38 am
Location: Antipolo City, Philippines

Re: ajax async:false can not work in google chrome 4.0

Postby ericlin328 on Fri Feb 26, 2010 9:38 am

wowenkho wrote:meh no wonder. you can't get it by alerting that way. you need to WAIT for the response to get back before you can actually alert and expect a value. i'm not sure what exactly but i know the Ajax class should have something like an onComplete or onSuccess event method. you can do your req.transport.responseText there.


i had tried to call onComplete function , still not work on google chrome for synchronous

  1.  
  2. url = 'index.php?option=com_fsite';
  3.   var req = new Ajax(url, {
  4.           method:'POST',
  5.           async:false,
  6.           data:'&format=raw&task=getok&captcha_work='+josfm.captcha_work.value ,
  7.           onComplete : function (ans){
  8.            alert(ans='+ans);
  9.           }
  10.   }).request();
  11.  
  12.  


and call a simple function following as :
  1.  
  2.  
  3. if ( window.XMLHttpRequest ){
  4.     req = new XMLHttpRequest();
  5.   } else if ( window.ActiveXObject() ) {
  6.     req = new ActiveXObject("Microsoft.XMLHTTP");
  7.  }
  8. req.open("GET", url, false);
  9. req.send(null);
  10. if (req.status  == 200) {
  11.   alert('req.responseText='+req.responseText);
  12. } else {
  13.   alert("There was a problem retrieving the XML data:\n" + req.statusText);
  14. };
  15.  


or
  1.  
  2. req.onreadystatechange=funciton(){
  3.     if (req.status  == 200) {
  4.         alert('req.responseText='+req.responseText);
  5.     } else {
  6.         alert("There was a problem retrieving the XML data:\n" + req.statusText);
  7.                }
  8. };
  9. req.open("GET", url, false);
  10. req.send(null);
  11.  


still not work on google chrome
so , synchronous can not correct work on google chrome ??
ericlin328
 
Posts: 5
Joined: Tue Feb 02, 2010 9:45 am

Re: ajax async:false can not work in google chrome 4.0

Postby wowenkho on Fri Feb 26, 2010 11:06 am

first of all, you had a problem with your mootools code where you used alert(). another thign is to try using console.log() instead of alert(). i don't see any reason why chrome won't make synchronous stuff to work
my sword is yours...
http://wowenkho.com

for those who want to talk with me quicker, add me on Yahoo! Messenger through my ID: michaelapeles
User avatar
wowenkho
mootools freak
 
Posts: 1146
Joined: Sat Aug 15, 2009 10:38 am
Location: Antipolo City, Philippines

Re: ajax async:false can not work in google chrome 4.0

Postby ericlin328 on Fri Feb 26, 2010 11:43 am

wowenkho wrote:first of all, you had a problem with your mootools code where you used alert(). another thign is to try using console.log() instead of alert(). i don't see any reason why chrome won't make synchronous stuff to work


my english is a little weak. maybe i no definite know how to express my problem and not used full mootools syntax on this case.
please forgive me if I make any errors.
ericlin328
 
Posts: 5
Joined: Tue Feb 02, 2010 9:45 am


Return to Help

Who is online

Users browsing this forum: No registered users and 1 guest