cancel
Showing results for 
Search instead for 
Did you mean: 

Ajax calls and firefox

sihnu
Champ in-the-making
Champ in-the-making
Hey,

recently I noticed that Ajax webscripts calls are always returning an empty object when I'm using Firefox. Here is an example structure showing how I call my webscripts:

url = Alfresco.constants.PROXY_URI + "path/to/my/webscripts"
Alfresco.util.Ajax.jsonGet({
  url : url,
  successCallback : {
    fn : function (res) {
      var result = eval('(' + res.serverResponse.responseText + ')');
      // Here I get empty result with Firefox but with Chrome it's ok
    },
    scope : this
  },
  failureCallback : {
    fn : function() {
      // whatever I want to do when error occurs
    },
    scope : this
  }
});


Why are the webscript calls failing with Firefox and working perfectly fine with Chrome?
3 REPLIES 3

rjohnson
Star Contributor
Star Contributor
Assuming you have made your slingshot return JSON then you would better use
res.json rather than eval'ing the return.

sihnu
Champ in-the-making
Champ in-the-making
Hey,

thanks a lot for your reply. The problem is not who I'm forming the json because the json in the response is empty. You are right I should use res.json because that's the right way to do it. However, the property res.json is just an empty object {}. Same goes to response text which is just "{}".

Anyway, I got new information. I noticed something weird. It's not really about the ajax call. Even though I do try to call the webscript using browser directly (writing the webscript path to address bar and pressing enter) I will get just empty object. However, if I do the same with Chrome I can get the correct response. Then I noticed something strange again. When browsing my webscripts at share/page/index/all with Firefox I can't see the webscripts but with Chrome I can see those. I can only see the webscripts with Firefox that I have deployed using classpath but not those I've uploaded to repository. Refreshing webscript index didn't help.

Still I get some response with Firefox when calling the webscript because it's returning an empty object. So I'm sure that the webscript is deployed. And of course I can be sure of it because it works fine with Chrome. One thing more is that I do run those webscripts which are deployed to classpath as an admin. I'm not sure if that has something to do with that. I still have to test it. Adding alf_ticket to the webscript call with Firefox didn't help.

Any idea what is going on here? Firefox being moderately popular browser I would assume other people have found the same problem.

sihnu
Champ in-the-making
Champ in-the-making
I could solve the problem. It's not about the Ajax call. It's actually about Lucene search. My webscript did lucene search against a property of my custom model. I noticed when I used whitespace in the queries I got always empty results but only when using Firefox. With Chrome it was fine. I then started to do some research and found out the property of my custom model was tokenized and so Lucene couldn't find the node if whitespaces were used in the query. I changed the property to non-tokenized, reindexed lucene indexes and the webscript started to work! So happy about this. Sorry though that I lead you in the wrong direction with the ajax calls.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.