Xmlhttprequest is working without a web server! why?

i have made an synchronous XMLHttpRequest request without a web server connection! when i need a web server i usually use xampp but i did my test without xampp and it works. I have just tested my code in a normal web browser (Google Chrome) !! sorry if this is too obviously but its does not to me.

this is the reason cause i am asking
w3school : The XMLHttpRequest object is used to exchange data with a server behind the scenes.

Hi @Schleswig

I think you might be in the wrong place–this is for the forum for the Particle (formerly called Spark) Arduino-like devices that are basically tiny computers with WiFi or cellular connections. This is not a forum about Apache spark.

So does your question pertain to Particle devices?

1 Like

Hi thanks for answer my question! Yes know this is for the forum for the Particle.
I’m using a Spark Core v1.0 to test it i have made a web page (html,css,javascript)!! but this was tested in a web browser like this :
“C:\Users\RONALD\Documents\IMK\WEB_PROGRAMMING\Wirless_Service\index.html”… and it works!! sweet :smiley:
Now my question is, Why it is working without a web server? Every device(Spark Core, Photon, Electron) has a URL… right? and All requests to the device come through API server using TLS security… right? so if i want to make a request through API server, do i need a real web page like www.test.com to have an access to web server?.. I don’t know if this is the rigth place to ask but i just see a lot of people using this XMLHttpRequest in many Spark Core tutorials to get the data, here is my code:

var xmlHttp = new XMLHttpRequest();
xmlHttp.open( “GET”,“https://api.spark.io/v1/devices/54ff72066678574ABC120667/data?access_token=<>”, false );
xmlHttp.send( null );
var obj = json_parse(xmlHttp.responseText);

If I’m understanding you right, you’re asking if you need to have your own server of some sort to access the Particle API? The answer is no. The Particle API relies on simple GET and POST requests, which any web browser can do, without any other support structure. For example, you’re code (which you shouldn’t display the access_token in when posting on the forum… @Schleswig, or @bko could you edit it so it’s not in there?), simply access the https url with a GET request. you could even take your url, and paste it into the web browser, and see the raw json response that way.

1 Like