I work with extjs and I use chrome to test my application
in my jsp page I use this code:
function changeContent(url) {
$( "#cmpframe" ).load( url, function( response, status, xhr ) {
});
}
<div id = "cmpframe"></div>
changeContent("http://192.168.100.25:8282/bonita/portal/homepage?ui=form#form=test--1.0--Step1$entry&mode=form&task=60002&assignTask=true");
But when I try to run my page I have this error :
XMLHttpRequest cannot load http://192.168.100.25:8282/bonita/portal/homepage?ui=form. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
this error is related to security .
I add this code without success :
$( "#cmpframe" ).load( url, function( response, status, xhr ) {
response.addHeader("Access-Control-Allow-Origin", "*");
});
updated :
I try alse with this code
$( "#cmpframe" ).load( url, function( response, status, xhr ) {
response.addHeader("Access-Control-Allow-Origin", "*");
xhr.setRequestHeader("http://192.168.100.25:8282/bonita/portal/homepage?ui=form#form=test--1.0--Step1$entry&mode=form&task=60002&assignTask=true", "XMLHttpRequest");
});
but I have also this error :
XMLHttpRequest cannot load http://192.168.100.25:8282/bonita/portal/homepage?ui=form. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
in web.xml of tomcat server :
I added this code :
<!-- ================== Built In Filter Definitions ===================== -->
...
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- ==================== Built In Filter Mappings ====================== -->
but I have this error :
java.lang.ClassNotFoundException: org.apache.catalina.filters.CorsFilter