Jepsson
Jepsson

Reputation: 35

Implementing a very small HTTP server in c/c++ and want to use AJAX

I want to have a dynamic webpage that automaticly updates some information, this information should be received from my c/c++ application using HTTP. I have set up a socket and can send HTML and Javascript files to the browser.

I don't know how to move on. How to encapsulate my data into XMLHttpRequest objects? Or maybe this isn't the way to go? The problem is that my c/c++ application will be run on an embedded system that can't really support php or something like that.
I can't really understand how XMLHttpRequest works, I only find a lot of client examples on the web and not much about how a server should handle it.

Upvotes: 2

Views: 1421

Answers (3)

Luchian Grigore
Luchian Grigore

Reputation: 258598

How do you send information to the browser? The browser is client-side. To get information, you must either query the server (which you say is written in C++). If you want your client to receive request, you should probably emulate a server-like behavior using NodeJS.

Upvotes: 0

lostyzd
lostyzd

Reputation: 4523

Ajax just send normal HTTP GET POST ... request, you should make sure your response header is correct, such as Content-Type.

Upvotes: 0

gnud
gnud

Reputation: 78518

A server should handle it as any other request. From the servers point of view, it's a normal HTTP request. Return the data that the client asks for! This is usually a HTML fragment, some XML or some JSON.

Upvotes: 4

Related Questions