分類彙整: Ajax、jQuery、javascript

Ajax-Origin ‘http://localhost:8080’ is therefore not allowed access

Ajax response console show

XMLHttpRequest cannot load http://127.0.0.1:8080/jerseyStock/services/stockJersey/getStock?stock_id=0050&stock_name=. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:8080’ is therefore not allowed access.

Create a new filter, which will set the header response

螢幕快照 2015-05-21 15.25.43

Edit web.xml add those lines

螢幕快照 2015-05-21 15.29.06