In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to solve the problem of ajax failure in google chrome browsers. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
Problem analysis: my ajax code works well in IE browser, IE core browser, and Firefox, but it gives me a headache in GOOGLE CHROME and always doesn't show the correct results.
My native development environment is as follows:
Google chrome version 28.0.1469.0m
Server Tomcat6.0
The code for 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:
Front page section:
$(document) .ready (function () {$("# searchBlack") .click (function () {$.get ('${requestScope.basePath} searchRecordBlackListByCardId.json', {cardId: encodeURI ('123456789')}, function (data, textStatus) {alert (data.pwCardSpeciallist.cardId);}, 'json'); return false;})})
For the above problems, give three screenshots and you will know why.
First, when accessed with a localhost:8080/cardDemo/searchRecordBlackList.html# address:
Second, when using 127.0.0.1:8080:8080/cardDemo/searchRecordBlackList.html# to access:
Third, 192.168.1.100:8080/cardDemo/searchRecordBlackList.html# when accessing using my native IP
It turns out that google chrome is forbidden to access local ajax resources due to the need of a certain security policy! This is still a bit of a fool, after all, the company I worked for claimed to be "only supporting GOOGLE CHROME browsers" on some projects.
This story tells us. When debugging later, try to use native IP to access the server, rather than 127.0.0.1 or localhost, so you don't spend hours looking for this error as I did.
On how to solve the problem of ajax failure in google chrome browsers to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.