
Untitled
By: a guest on
Jul 31st, 2012 | syntax:
None | size: 1.58 KB | hits: 13 | expires: Never
$.ajax not working for GET
<report>
<id>420</id>
<checksum>339d9146ddd3d6646a1fe93ddf4d7ab8c4a51c61</checksum>
<checksumValid>true</checksumValid>
<reportName>sprawozdanie 1</reportName>
<userName>John Smith</userName>
<state>robocze</state>
</report>
$.ajax({
type:"GET",
url:"http://127.0.0.1:5050/rest/rest/report/check/" + obj.id + "/" + obj.checksum + ".xml",
success:function (data, textStatus) {
alert('success...');
},
error:function (xhr, ajaxOptions, thrownError) {
alert("thrown: '" + thrownError + "', status: '"
+ xhr.status + "', status text: '"
+ xhr.statusText + "'");
}
});
public class OptionsHeadersFilter implements Filter {
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
throws IOException, ServletException {
HttpServletResponse response = (HttpServletResponse) res;
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Methods", "GET,POST,PUT,DELETE");
response.setHeader("Access-Control-Max-Age", "360");
response.setHeader("Access-Control-Allow-Headers", "x-requested-with");
chain.doFilter(req, res);
}
public void init(FilterConfig filterConfig) {
}
public void destroy() {
}
}
<filter>
<filter-name>OptionsHeadersFilter</filter-name>
<filter-class>poi.rest.OptionsHeadersFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>OptionsHeadersFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>