/    Sign up×
Community /Pin to ProfileBookmark

AJAX and JSON

Hey folks, I’ve been working with this XMLHttpRequest code, and I’m having something new crop up. In console.log I’m getting a redirection problem with my request. The actual error message says “Redirect was blocked for CORS request”. I’m not sure how this is happening, or what it means. I could use some direction on this – – okham

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@rootFeb 27.2017 — It helps to see what your code for it is and how you are forming the URL, if you are using an AJAX call to another domain, then that will be the problem, a Cross Origin Resource Sharing problem, like if you are on mydomain.com and you have a URL theotherdomain.com as the URL, you can't do that, all requests have to be on the original mydoamin.com URL.
Copy linkTweet thisAlerts:
@okhamauthorFeb 27.2017 — I read something about that...there not being any cross-domain sharing. Well, I finally moved my XML request into the scope of my base function, instead of calling it from a separate function. I couldn't figure out how to pass the responseText back to my original function...using return didn't solve the problem. Anyways, I just put the request in-line of my original function, and that seemed to solve the problem. I have to admit, working with JSON has been easier that with .js, although there's more risk of syntax errors with all the quotations and commas. I had to break myself of using "=" and move to colons. I finally got all my item files rewritten in JSON. Incidentally, do you know of a resource that has an exhaustive list of the DOM?
Copy linkTweet thisAlerts:
@rootFeb 27.2017 — You can either make the response to a global variable or update a DOM element or JSON.parse it in to a variable or you can use the callback mentod and have the response passed to an external function... as you will find in the AJAX example I posted you in a previous threat, there were two examples, on basic one and a callback one..
×

Success!

Help @okham spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...