Wicket.Ajax.Call.failure: Error while parsing resp

2019-07-01 09:48发布

I just spent several hours of my life debugging this problem. I'm documenting it here for others.

Question:

I'm getting the following error when I try to click on an AjaxLink in Internet Explorer:

Wicket: ERROR: Wicket.Ajax.Call.failure: Error while parsing response: Object required

It works fine in all other browsers; just IE is busted.

标签: ajax wicket
2条回答
疯言疯语
2楼-- · 2019-07-01 10:14

I want to note one more potential reason for the issue with Wicket's AJAX in IE. It might help someone, who encounters similar problem.

In my case I had the following error message in IE:

Wicket: ERROR: Wicket.Ajax.Call.failure: Error while parsing response: could not find root <ajax-response> element

The reason was an incorrect Content-Type of AJAX response. I used AbstractTransformerBehavior and there was a bug in Wicket 1.4.x so this behavior was rewriting response Content-Type with text/html. IE does not parse such response as XML.

查看更多
甜甜的少女心
3楼-- · 2019-07-01 10:22

Check to make sure that your HTML is 100% syntactically correct. Ajax responses are returned to the browser inside a CDATA section, and if the payload is not well-formed, IE will sometimes choke.

In my case I neglected to close a <link> tag in the <head> section. Simply closing that link tag made all the difference.

Aside: if you ever come across a tough-to-solve problem in Wicket, it's a good idea to create a quickstart project that reproduces your issue. It can be a lot of work to boil things down, but in doing so you often find the source of the problem.

查看更多
登录 后发表回答