XMLHttpRequest

BlitzMax Forums/BlitzMax Programming/XMLHttpRequest

jsp(Posted 2012) [#1]
I need to send a XMLHttpRequest from BlitzMax to a certain server port, but have no idea yet.

Anybody done that before and has some snippet I can begin with?

I do have a xml file which has to be transferred and should be processed on the server side and return some status messages.


ProfJake(Posted 2012) [#2]
You have to send a POST request to the server with the XML file as a field.
To simulate a XMLHttpRequest you can set the HTTP header "X-Requested-With" to the value "XMLHttpRequest".
This is what most AJAX scripts do.


jsp(Posted 2012) [#3]
Thanks, will try if it helps.
Don't have access to the server atm but the last try ended in "Bad Request"...
I checked the wiki and it looks like it differs a lot more than I thought from a normal HTTP POST command.


ProfJake(Posted 2012) [#4]
With Firebug (Addon for Firefox) and others like it, you can see the HTTP messages between your browser and the server.

You can check what you need by visiting a site that does something similar, or the server you want to contact if it has a web frontend.
Than all you need to do is to open Firebug and see what the server expects.


jsp(Posted 2012) [#5]
Not really a success but may a bit closer, I do get now an error in xml instead of bad request.
I tried the "X-Requested-With" field, but it is the same with or without.

The idea with FireFox is nice but then it can't send the http POST command, or I don't know how. Probably with a html form, but that is not what I want to simulate, I think.
I downloaded a http send test tool and I got it working from there but unfortunately it tells me only the response but not exactly what it sends. If I could only see what I need to send or what the server got from my request, it would probably quite simple to adjust in the code.