I have a problem connecting javascript and c# (Windows forms) using http requests. I have a JS code like this:
ext.get_led = function ( callback) {
// Make an AJAX call to the Open Weather Maps API
$.ajax({
url: 'localhost:12754/poll',
dataType: 'text',
success: function (data) {
// Got the data - parse it and return the temperature
callback(data);
},
failure: function () {
callback("Null");
}
});
};
that is supposed to send an ajax request to the Windows Forms app. The Problem is that whenever I try to execute this function, the Javascript console shows an error:
In the link it gave me (http://ift.tt/1eceNme) there's this: "Client/server version mismatch: Unsupported client"
My c# code looks like that:
public class MyHttpServer : HttpServer
{
public int busy;
public bool isSpeaking = false;
public float result;
public MyHttpServer(int port)
: base(port)
{
}
public override void handleGETRequest(HttpProcessor p)
{
if (p.http_url.Equals("/poll"))
{
p.writeSuccess();
p.outputStream.WriteLine("SCRATCH");
p.httpHeaders = new Hashtable { { "Access-Control-Allow-Origin", "*" }, { "Content-Type", "text/plain"} };
return;
}
}
public override void handlePOSTRequest(HttpProcessor p, StreamReader inputData)
{
}
}
There are another 2 classes in the c# code, but their code is very long, so I won't put it here. I once tested the whole system with communication between 2 apps (not app-web), and it was working perfectly. But, when I wanted my app to communicate with the web, it refuses. The error says something is wrong with my client, but I have no idea what (Also the client - ajax - was tested and working fine).
Whoever helps, thank you.
Aucun commentaire:
Enregistrer un commentaire