How to troubleshoot Ajax in Google Chrome browser failure _ajax related

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.