Forum Discussion

jc758's avatar
jc758
Advisor
13 years ago

Json issue with ie 9 / FF 12 XP


Hi,

i'm currently updating our website to see if the current visitor is logged our community...

I make an api call with jquery, using jsonp to avoid cross domain restriction...

$.ajax({ url:"http://lithosphere.lithium.com/restapi/vc/authentication/sessions/login?xslt=json.xsl",
         Type:"GET" ,
         dataType:"jsonp",
         success: function(data){
          alert('$.ajax: ' + data.response.status);
         }
        });  

 
   or
   

$.getJSON("http://lithosphere.lithium.com/restapi/vc/authentication/sessions/login?xslt=json.xsl&callback=?",
        function(data){
          alert('$.getJSON: ' + data.response.status);
      });    

 



My problem is that it doesn't work neither on Firefox 12 on Windows XP nor on IE 9/Windows 7 (don't know if it is the same problem (charset for IE?))
if I call the url directly on my browser, i've got a success response, but calling the url with jquery , it always returns an error response (user authentication failed)...
Works fine on other browser (FF12 on windows 7, even IE 7 on XP ;) )

Does anybody has any ideas to fix this?

Thanx

4 Replies

  • ok , it works in FF (maybe something weird in my configuration)

     

    but doesn't work on IE 9...

     

    when trying to access the api :

    http://lithosphere.lithium.com/restapi/vc/authentication/sessions/login?xslt=json.xsl

     IE give a prompt "Do you want to open or save" the file, instead of displaying the json... but the response body is ok ...

     

    But via ajax, always have

    "jsonp1337172818369({"response":{"status":"error","error":{"code":302,"message":"User authentication failed."}}});"

     

     

     

    a little help would save my day ;)

     

  • KaelaC's avatar
    KaelaC
    Lithium Alumni (Retired)
    13 years ago
    When you get the correct json response back are you logged into the community? I think what you are seeing is that your ajax call is anonymous and that "user" does not have access to make that call.
  • Hi thanx for the reply...

     

    Well , i verified, and i am logged in in the browser...

     

    if i'm not wrong , the ajax function call the  rest api which only show if a user is logged on on the same browser... it fails only on IE 9...

     

    if i load the page http://lithosphere.lithium.com/restapi/vc/authentication/sessions/login?xslt=json.xsl&callback=? directly in IE 9 

    my headers look like that:

    IE9-direct-header-send.jpg

     

    Then i get this response:

    IE9-direct-reponse.jpg

     

     

    Calling the same page with ajax (logged in in the lithosphere / same browser's window) :

    IE9-ajax-header-send.jpg

     

    the response:

    IE9-ajax-response.jpg

     

     

    regards