0

This error occurs when I am trying to retrieve a "xml" response using a fetch in backbone.

my fetch code is :

itenary.fetch({
data :{date:dayFormatToSend.toString(), advisorId:"0000222186"},
dataType:"xml",
 success:function(response){
  console.log(response);
     } 

error

Uncaught Error: SecurityError: DOM Exception 18 backbone-min.js:13
f.extend.set backbone-min.js:13
a.success backbone-min.js:15
c.success backbone-min.js:40
fire jquery-1.8.0.js:973
self.fireWith jquery-1.8.0.js:1080
done jquery-1.8.0.js:7583
callback

This happens only when I have the dataType set to "xml" and if otherwise the success function wouldn't execute succesfully.

Also I could see the response properly in the network window in chrome browser inspect element window.

This happens only in chrome and it works fine with firefox

digToGetWater
  • 171
  • 2
  • 9
  • I'm not sure what your question is or what troubleshooting techniques you've tried? Have you looked at this: http://stackoverflow.com/questions/15200745/backbone-js-collection-call-xml-file-using-this-fetch-error – WiredPrairie Mar 22 '13 at 10:59
  • my backbone fetch returns a DOM Exception security error while I am trying to "get" a "xml" response. If I do not mention the part datatype:"xml" then the call happens but the success function is not being called at all. I checked the link you mentioned but thats not the same. That is about how you can handle the xml response in the parse function while mine is not even completing the fetch properly – digToGetWater Mar 22 '13 at 14:37
  • Have you tried to simplify your XML documents? Is it all XML returned, or just some that is causing the problem? Did you look at this: http://stackoverflow.com/questions/2704929/uncaught-error-security-err-dom-exception-18-when-i-try-to-set-a-cookie? – WiredPrairie Mar 22 '13 at 15:05
  • This doesn't happen in all the xml document. Only a particular one. The link you provided talks about web workers and local storage. I am not using either of that. – digToGetWater Mar 27 '13 at 04:37
  • The answers were also talking about files being served locally, not via HTTP. I'd suggest modifying the XML until it works. See if you can't narrow the problem down. – WiredPrairie Mar 27 '13 at 10:39

1 Answers1

0

I fixed this by adding a try catch around BB source in 1.0.0 around line 345. To something like this:

// For each `set` attribute, update or delete the current value.
        for (attr in attrs) {
            try {
                val = attrs[attr];
                if (!_.isEqual(current[attr], val)) changes.push(attr);
                if (!_.isEqual(prev[attr], val)) {
                    this.changed[attr] = val;
                } else {
                    delete this.changed[attr];
                }
                unset ? delete current[attr] : current[attr] = val;
            } catch (err){
                if(window.console) console.log(err);
            }
        }

The issue appears to be when it hits the 'cookie' property it goes bonkers and throws the security violation in Chrome. Trying to call attrs[attr] equates to document[cookie] which causes the Kaboom. Not sure exactly what security policy in Chrome violates, but the try catch allows the code to continue executing and complete the request as desired and hands back the xml as expected.

I hacked this into the 1.0.0 min at http://jsfiddle.net/ctoestreich/UwRDp/

Christian
  • 297
  • 1
  • 4