Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

jquery - Illegal operation on WrappedNative prototype object

I'm sorry if this answer seems similar to other questions in this website, but I couldn't find what I need.

I have this code:

    $.ajax({
            url: '../../cgi-bin/executeQuery',
            type: 'GET',
            data: ({siid:5185,of:"xmlWithColID"}),
            dataType: 'xml',
            success: function(xmlR){
                    try{
                            $.ajax({
                                    url: '../../cgi-bin/authList.py',
                                    type: 'GET',
                                    data: ({xmlToFormat:xmlR,service:"paperList"}),
                                    dataType: 'xml',
                                    success: function(data){
                                            try{
                                                    displayResult(data,loadXMLDoc("js/authList/paperTableStyle.xsl"),"divPaperTable");
                                            }catch(e){
                                                    console.log(e.message);
                                            }
                                    },
                                    complete: function(XMLHttpRequest, textStatus){
                                            $('#divMakingAuthorList').addClass('secondary');
                                            $('#divMakingAuthorList').hide();
                                    }
                            });
                    }catch(e){
                            console.log(e.message);
                    }
            }
    });

That gives me the following error in FF: "Illegal operation on WrappedNative prototype object".

When I removed the "success" part of my code, the error message was still there. After, I removed the "complete" parte and the error message was there too. But then, when I removed the following line of my code: data: ({xmlToFormat:xmlR,service:"paperList"}), The message was gone.

But I don't understand the reason. Is it possible to send "xml" to my CGI as data in an ajax event?

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

That error message typically refers to when you try to wrap a native function like for instance "eval"

If you do something like this -



(function() {

   var t = eval;

   eval = function() {
      t.apply(window, arguments);
   }

}();

Firefox won't allow you to use eval anymore because the function signature no longer matches it's internal reference point and it considers this a devious tactic. I think it's completely stupid and violates the very premise of javascript's flexibility, but it's what we now have to deal with.

Same goes for something like var x = document.createElement; calling x('div') will make firefox whine like an emo teen.

My guess is that when xmlR is not passed to the second ajax request the request fails and so your success block is never called. I know you mention that you tried the call without the success block and you still saw the message but maybe you could try again with an empty success function to confirm.

I'd check out what's going on in displayResult and loadXMLDoc - and I believe the illegal operation safety checks were recently added to FireFox so if you can try an older version like 3.0 you might confirm this distinction.

Otherwise I don't see anything glaring with the code you provided and sending xml data is completely valid with ajax.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...