• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Ajax and Firefox

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
This is a html page with AJAX.
The code is working perfectly in Internet Explorer but is not working in Firefox.
The result is a simple JSON object. I also tried jQuery but the result was the same.
Does anybody know how to get the code working in FF?



Thanks,
Roman
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just out of curiosity, what happens if you use <div></div> instead of <div/>?
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<div/> is not valid and will not work.
 
Roman Mazur
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"<div/> is not valid and will not work. "

Are you saying that the code is not working in FF because of the div?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What else would "<div/> is not valid and will not work" mean?! Did you even try it?
 
Roman Mazur
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I changed the div in the code but the result is the same (it is working in IE but not in FF)

Roman
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I find that difficult to believe; can you access the div from the Firebug console?
 
Roman Mazur
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
The div is not that important. You can display the result in different way like javascript alert().
I think the point is that the request object is null in FF.

Roman

 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well if you're not even making a *request* properly, sure, I guess it would have been good to include that info earlier.

I haven't done Ajax w/o a framework for years--no point, so I won't be able to help with your JavaScript code.
 
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Roman Mazur wrote:
I think the point is that the request object is null in FF.



Note the case. It should be
request = new XMLHttpRequest();
 
Roman Mazur
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I changed it but it didn't help.
This is the current code:
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...


if (window.xmlhttprequest) {

Seriously, why wouldn't you use a framework and skip all this manual, obviously error-prone stuff?
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Roman Mazur wrote:I changed it but it didn't help.



Noticed the other mistake now, again in the case. Should be:
if (window.XMLHttpRequest)...

There is no entity named "xmlhttprequest" in window either - it'll always be false.

I too feel that if you're going to use ajax a lot, better to use one of the frameworks - jquery, dojo, etc.
 
Bear Bibeault
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Karthik Shiraly wrote:I too feel that if you're going to use ajax a lot, better to use one of the frameworks - jquery, dojo, etc.


Seriously! All this code usually boils down to a single statement when using jQuery.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That code should fail in any browser that has good security measures set.

JavaScript has a same origin policy. That means you can not call or interact with other domains. I am betting the error message you are getting is access denied.

You are trying to call a URL that is on a different domain with Ajax. That is not going to happen without a proxy. Most web services now support JSONP and some browsers support CORS.

Eric
 
Roman Mazur
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like there is now way to run this code in FF.
I will look for different solution.

Thanks,
Roman
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like JSONP? Since obviously there are a million map mashups?
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Roman Mazur wrote:It looks like there is now way to run this code in FF.
I will look for different solution.

Thanks,
Roman



You should not be able to do it in IE. Your settings allows sites to interact with other sites. That is not secure.

Eric
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
you can read security issues related to the ajax making call to diiferent domains from following website link:
http://www.xml.com/lpt/a/1627
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
(With the caveat that the article is five years old and doesn't include recent developments, like JSONP.)
 
I'm just a poor boy, I need no sympathy, because I'm easy come, easy go, little high, little low, little ad
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic