jquery ajax problem in chrome

后端 未结 8 1046
南旧
南旧 2020-11-28 07:41

i have the following jquery code running on my page just fine in FF and IE, but chrome seems to be freaking out..

in FF and IE the call is made and the result is app

8条回答
  •  清酒与你
    2020-11-28 08:22

    I just saw that this question has gotten a lot of views, and its still open. I'd forgotten about it completely and hopefully this will let me close it.

    Setting the datatype argument to nothing, or even removing the datatype argument completely will solve the problem.

    In my example I am returning a rendered view (an html snippet in string) and in this code I'm specifying the data type to json, when really it isn't. Most other browsers seem to ignore the datatype if its incorrect and move on with life, allowing me to append the html result.

    Chrome throws an error. The status text is OK, the status code is 200, because the actual ajax request went through fine. The problem has nothing to do with the request itself, the problem is that the data returned is not what I told chrome it would be.

    So chrome breaks. If I remove the datatype argument completely chrome figures out what the data is when it gets it. If I set the datatype argument to "html" then it also works fine.

    Long story short, the problem is not chrome. Its me. Because I'm dumb like that. I am marking this as the answer to this question as it answers the example I presented in the original question.

    In the comments others have described other situations where this solution is most likely not going to help.

提交回复
热议问题