Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XMLHttpRequest cross site scripting?

Tags:

javascript

I realize this issue of cross site scripting has been covered, however being new to web development I had a few further questions.

Currently I am testing an html file I wrote on my PC connecting to a RESTFul web service on another machine. I am getting status=0. Is this considered cross-site scripting?

If a server hosts a file with javascript, and that javascript file has XMLHttpRequests to the server's own web services, will that work, or is that bad?

Apologies if any of these questions are stupid.

like image 912
qin_23 Avatar asked Mar 14 '26 13:03

qin_23


1 Answers

status=0 can me a variety of things, and without knowing more about how you got to that point, it is very difficult to determine what, exactly, it means. You could be using an iframe, the other computer could genuinely be telling you that the status is 0... we don't know.


The general rule is that it doesn't matter where the JS is from, it will execute the data where it's loaded. This is what makes the Google js archiving api possible (you know, use https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.js on a whole assortment of locations). And honestly, that is not a security issue.

The security issue comes in when a js file tries to access another domain (or even subdomain), whether through manipulation of an iframe or through XMLHTTPRequest. It's at that point that the browser will "lay the smackdown" on the script.

You will have difficulty communicating with JavaScript from your hard drive (file:///) to any internet protocol (http|https) because of this.

like image 147
cwallenpoole Avatar answered Mar 17 '26 02:03

cwallenpoole



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!