Jump to content

JSON in internet explorer

myselfolli
Go to solution Solved by duncannah,

Oh yeah, caching is quite likely the culprit. Set the 'cache' option to false in $.get

Alright, so I've been working on a website on which I can view the content of a database. I use jQuerys AJAX to query a PHP script, which handles the database interaction and returns the result as JSON. This all works fine in Chrome and Firefox, but IE is - as per usual - being a little b*tch.

 

For some bizarre reason the returned JSON is empty in IE, while it contains the correct data in Chrome and FF:

image.png.64b17e69a63aebfd9fb0f992816da0ef.png (taken in Chrome)

 

image.png.08208258040f5f0a677ca1cd26041aaf.png (taken from IE)

 

It's the same PHP script, queried literally seconds apart. Does anybody have any ideas why the Internet Explorer doesn't want to comply? I'm totally lost

75% of what I say is sarcastic

 

So is the rest probably

Link to comment
Share on other sites

Link to post
Share on other sites

Is the IE screenshot from the HTTP response, or from the console (result from a JavaScript function)?

🙂

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, duncannah said:

Is the IE screenshot from the HTTP response, or from the console (result from a JavaScript function)?

From the HTTP response

75% of what I say is sarcastic

 

So is the rest probably

Link to comment
Share on other sites

Link to post
Share on other sites

Actually I think I have an idea

 

IE doesn't like displaying JSON directly on the website, it instead prompts you to download the JSON file. But since my AJAX request essentially only scrapes the content from the website, it returns an empty JSON array...

75% of what I say is sarcastic

 

So is the rest probably

Link to comment
Share on other sites

Link to post
Share on other sites

Are you sending any data to the server (URL parameters and/or POST data)? Maybe try doing `var_dump($_GET); var_dump($_POST);` to see if there's any difference between the browsers

🙂

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, duncannah said:

Are you sending any data to the server (URL parameters and/or POST data)? Maybe try doing `var_dump($_GET); var_dump($_POST);` to see if there's any difference between the browsers

Nothing, no. It's a pure $.get

75% of what I say is sarcastic

 

So is the rest probably

Link to comment
Share on other sites

Link to post
Share on other sites

God I hate the Internet Explorer

75% of what I say is sarcastic

 

So is the rest probably

Link to comment
Share on other sites

Link to post
Share on other sites

Do you really mean IE? or are you talking edge?

 

If you are testing in IE there is a simple solution to this. Don't test in IE. It's a dead program, MS hasn't supported it for years. 

 

If the issue is with Edge then most likely you are suffering from the "fastest browser on earth" syndrome. MS really do have a fast browser, but they achieve this by insanely heavy caching of pages. If your URL doesn't change (which it wont for the same call) then edge will just load up what you have in memory, which is nothing at that point, you need to add a "cache buster" to the end of the URL being called for edge to even attempt to request the new data. (there are other ways, but that is the most simple)

 

The problem is not quite as simple as I explained (it's more than just heavy caching) but the end result is you need to force edge to realise that you want brand new data. 

Link to comment
Share on other sites

Link to post
Share on other sites

Oh yeah, caching is quite likely the culprit. Set the 'cache' option to false in $.get

🙂

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, FlappyBoobs said:

Do you really mean IE? or are you talking edge?

 

If you are testing in IE there is a simple solution to this. Don't test in IE. It's a dead program, MS hasn't supported it for years. 

 

If the issue is with Edge then most likely you are suffering from the "fastest browser on earth" syndrome. MS really do have a fast browser, but they achieve this by insanely heavy caching of pages. If your URL doesn't change (which it wont for the same call) then edge will just load up what you have in memory, which is nothing at that point, you need to add a "cache buster" to the end of the URL being called for edge to even attempt to request the new data. (there are other ways, but that is the most simple)

 

The problem is not quite as simple as I explained (it's more than just heavy caching) but the end result is you need to force edge to realise that you want brand new data. 

I do actually mean the Internet Explorer. And since it's not a personal project, but one I have to do for work, I don't really have the option to not use IE.

 

Trust me I want to, but Martha over at HR is about 90 years old and everybody is proud of her for even figuring out how to turn on her PC (not really, but you get the idea)

75% of what I say is sarcastic

 

So is the rest probably

Link to comment
Share on other sites

Link to post
Share on other sites

3 minutes ago, myselfolli said:

I do actually mean the Internet Explorer. And since it's not a personal project, but one I have to do for work, I don't really have the option to not use IE.

 

Trust me I want to, but Martha over at HR is about 90 years old and everybody is proud of her for even figuring out how to turn on her PC (not really, but you get the idea)

Not even Microsoft themselves still develop for IE. It's only there to maintain compatibility with web services that run on Microsoft server operating systems, such as Certsrv, Exchange, older Sharepoint versions etc.

PC Specs - AMD Ryzen 7 5800X3D MSI B550M Mortar - 32GB Corsair Vengeance RGB DDR4-3600 @ CL16 - ASRock RX7800XT 660p 1TBGB & Crucial P5 1TB Fractal Define Mini C CM V750v2 - Windows 11 Pro

 

Link to comment
Share on other sites

Link to post
Share on other sites

You beautiful people, it worked. It ended up being the cache -.-

 

Thanks!

75% of what I say is sarcastic

 

So is the rest probably

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, NelizMastr said:

Not even Microsoft themselves still develop for IE. It's only there to maintain compatibility with web services that run on Microsoft server operating systems, such as Certsrv, Exchange, older Sharepoint versions etc.

I know, but it's an internal site and I'm forced to use IE. I've been trying to get everybody to switch over to Firefox, but nothing is really moving...

75% of what I say is sarcastic

 

So is the rest probably

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, myselfolli said:

I know, but it's an internal site and I'm forced to use IE. I've been trying to get everybody to switch over to Firefox, but nothing is really moving...

The best way is to remove the IE shortcuts and set Firefox as default, and call it Internet. 

PC Specs - AMD Ryzen 7 5800X3D MSI B550M Mortar - 32GB Corsair Vengeance RGB DDR4-3600 @ CL16 - ASRock RX7800XT 660p 1TBGB & Crucial P5 1TB Fractal Define Mini C CM V750v2 - Windows 11 Pro

 

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, myselfolli said:

I do actually mean the Internet Explorer. And since it's not a personal project, but one I have to do for work, I don't really have the option to not use IE.

 

Trust me I want to, but Martha over at HR is about 90 years old and everybody is proud of her for even figuring out how to turn on her PC (not really, but you get the idea)

 

I get the issue (i've been a programmer for a long time), but when edge came out we made a decision to simply never support IE again. Martha (we call her Birthe) in HR was told "IE is no longer supported, ask IT to upgrade your machines" and to our shock that's what they did (because every vendor was basically telling them the same thing). I noticed you mentioned that you are trying to get everyone to switch to firefox, this is a bad move, switching them to Edge is a much more likely option because they are more familiar and comfortable with MS than anything else, Firefox is unknown by most, and chrome is "that google company that steals my data and doesn't pay tax". (like I said, i've been there)

 

 

Anyway, since your boss will always make you do this "one last IE project" no matter if you are switching or not, we need to solve the issue. Can you post your HTTP headers that you are getting back? perhaps try in SOAP UI (supports REST as well) to make it easy to see what is being returned.

 

 

IE 11, has some strange quirks with some of the headers that can cause JSON to not display, mainly these are centered around security settings that IE 11 doesn't support but if you show what you have maybe we can help.

 

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, FlappyBoobs said:

 

I get the issue (i've been a programmer for a long time), but when edge came out we made a decision to simply never support IE again. Martha (we call her Birthe) in HR was told "IE is no longer supported, ask IT to upgrade your machines" and to our shock that's what they did (because every vendor was basically telling them the same thing). I noticed you mentioned that you are trying to get everyone to switch to firefox, this is a bad move, switching them to Edge is a much more likely option because they are more familiar and comfortable with MS than anything else, Firefox is unknown by most, and chrome is "that google company that steals my data and doesn't pay tax". (like I said, i've been there)

 

 

Anyway, since your boss will always make you do this "one last IE project" no matter if you are switching or not, we need to solve the issue. Can you post your HTTP headers that you are getting back? perhaps try in SOAP UI (supports REST as well) to make it easy to see what is being returned.

 

 

IE 11, has some strange quirks with some of the headers that can cause JSON to not display, mainly these are centered around security settings that IE 11 doesn't support but if you show what you have maybe we can help.

 

 

 

Well switching them to Edge won't exactly be a long term solution either, since MS is dropping that as well (as seen/heard in a recent TechLinked).

 

And I did actually resolve the issue. But thanks for your help anyways ^^

 

P.s.: Say hi to Birthe for me :P

75% of what I say is sarcastic

 

So is the rest probably

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, myselfolli said:

God I hate the Internet Explorer

Then why are you supporting it?

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

18 minutes ago, vorticalbox said:

Then why are you supporting it?

Again, not by choice

75% of what I say is sarcastic

 

So is the rest probably

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×