Problem Analysis: My AJAX code in IE browser, 360 of IE Core Browser, as well as in Firefox are operating normally, but under Google Chrome but it makes me very headache, always did not show the correct results.
My local development environment is as follows:
Google Chrome version 28.0.1469.0m
Server Tomcat6.0
The code for the server-side spring MVC is as follows:
Controller section:
@RequestMapping (value= "/searchrecordblacklistbycardid.json") public
String Searchrecordblacklistbycardid ( HttpServletRequest request,httpservletresponse response,string cardid,modelmap mm) {
Response.setContentType (" Application/json;charset=utf-8 ");
Pwcardspeciallist pcs = Blacklistservice.getrecordblacklistbycardid (cardid);
Mm.addattribute ("Pwcardspeciallist", PCs);
return "Jsonview";
}
Xxx-servlet.xml configuration section:
<bean id= "Jsonview" class= "Net.sf.json.spring.web.servlet.view.JsonView"/> <bean id=
" Beannameresolver "class=" Org.springframework.web.servlet.view.BeanNameViewResolver ">
<property name=" Order "value=" 0 "/>
</bean>
<bean class=" Org.springframework.web.servlet.view.InternalResourceViewResolver "
p:viewclass=" Org.springframework.web.servlet.view.JstlView "
p:order=" "
p:prefix="/web-inf/jsp/"
p:suffix=". JSP "/>
Front Page section:
<script type= "Text/javascript" >
$ (document). Ready (function () {
$ ("#searchBlack"). Click (Function ( ) {
$.get (' ${requestscope.basepath}searchrecordblacklistbycardid.json ', {
cardid:encodeuri (' 123456789 ') )
}, function (data, textstatus) {
alert (data.pwCardSpeciallist.cardId);
}, ' json ');
return false;
})
};
</script>
For the above problems, give three screenshots, you can know why ....
The first one, when using localhost:8080/carddemo/searchrecordblacklist.html# address:
The second one, when using the 127.0.0.1:8080:8080/carddemo/searchrecordblacklist.html# visit:
The third one, when using my native IP access 192.168.1.100:8080/carddemo/searchrecordblacklist.html#
Originally, Google Chrome is due to some kind of security policy needs, prohibit access to local AJAX resources! This is still a bit of a pit dad, after all, I was in the previous company in some projects known as "only support Google Chrome browser."
The story tells us .... When debugging later, try to use native IP to access the server side, instead of using 127.0.0.1 or localhost, so that it won't take me a few hours to find this error.