Reputation: 381
In my polymer app, pulling in json data via iron-ajax element works fine, but I can't get it to work with my local json file. I've hosted the app on firebase, but still no luck.
This doesn't work:
<iron-ajax
auto
url="data/watchlist.json"
last-response="{{data}}"
handle-as="json">
</iron-ajax>
But, this does works:
<iron-ajax
auto
url="http://jsonplaceholder.typicode.com/albums/"
last-response="{{data}}"
handle-as="json">
</iron-ajax>
What am I doing wrong? Can't tell if I'm doing something wrong with polymer or with ajax/json calls.
Upvotes: 0
Views: 1364
Reputation: 657148
That is probably a browser limitation for security purposes.
Check the browser console you probably get an error that tells you why Chrome is blocking the request.
Start up a server that serves this file and fetch it from there. You need to enable CORS support on the server if it is a different one than where you load index.html
from.
Upvotes: 1