Creating a compact HTTP server in c/c++ and incorporating AJAX capabilities into it

Creating a dynamic webpage that can automatically update information is my goal. I've managed to establish a socket and send HTML and Javascript files from my c/c++ application to the browser.

However, now I'm stuck on how to proceed. How do I package my data into XMLHttpRequest objects? Is this the correct approach or should I be exploring other options? The challenge lies in the fact that my c/c++ application will be running on an embedded system that does not have robust support for php or similar technologies.
I'm struggling to grasp how XMLHttpRequest functions, as most of the resources available online only provide client-side examples without much guidance on how a server should manage it.

Answer №1

When a server receives this request, treat it like any other and respond accordingly. The server should view it as a typical HTTP request and provide the requested data to the client. This could be an HTML snippet, XML document, or JSON response.

Answer №2

When using Ajax, it is essential to send regular HTTP GET POST ... requests. It's important for the response header, like Content-Type, to be accurate.

Answer №3

One way to transmit data to the browser is by interacting with the client-side environment. In order to retrieve information, you typically need to make a request to the server (which may be programmed in C++). To enable your client to receive responses, one option is to replicate server functionality using NodeJS.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Combining the inline JavaScript linting tool ESLint with the popular Airbnb configuration and Facebook

In my current project, I am utilizing ESLint and looking to incorporate Facebook flow. However, I am encountering warnings from ESLint regarding flow type annotations. Within the project root directory, I have both .flowconfig and .eslintrc files present. ...

Hiding the keypad on an Android device in an Ionic app when user input is detected

I am currently utilizing the syncfusion ej2 Calendar plugin for a datepicker, but I am only using options such as selecting ranges like today, 1 month, or last 7 days from the plugin itself. The plugin provides dropdown options when the calendar is trigger ...

Utilizing AJAX capabilities with Mysqli, PHP, and jQuery for efficient web development

Is it possible to implement ajax in php and mysqli to dynamically display data from a database without the need for any user input, such as clicking a button? I want new information to be visible on the page instantly after adding a row to the table, witho ...

React.js: The function useDef has not been defined

Attempting to create a React.js calculator application, my initial step was to delete the entire src folder and replace it with a new one containing the necessary elements for the web app. Here is the content of the index.js file: import React,{ useEffect, ...

Tips for successfully implementing a timeout feature while establishing a connection with a socket

In attempting to implement a timeout for connect(), there are no reported errors from getsockopt(). However, when proceeding to write(), there is a failure with an "errno of 107 - ENOTCONN." Operating on Fedora 23, the documentation for connect() specifie ...

An exception was encountered at memory address 0x00007FF982801B5F in ntdll.dll while running ConsoleApplication3.exe. The error code 0xC0000005 indicates an access violation when attempting to read

Encountering the error message "Unhandled exception at 0x00007FF982801B5F (ntdll.dll) in ConsoleApplication3.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF" while attempting to set up a dynamic 2D array within a class. Here, we have ...

The Geocoder.geocode() method returns XML instead of JSON when invalid credentials are provided

Currently in the process of developing a program that converts addresses from a database to their corresponding lat/long coordinates using the HERE Geocoding API. In order for multiple users to utilize this program, they must manually input their app_id an ...

Discovering the geographical location of all users using Node.js: A step-by-step guide

My current task involves determining the geoip location of users. I have implemented a code that stores the user's address in the database and then displays the geoip location accordingly. However, if a user changes their location and logs in from a d ...

ng-repeat not functioning properly with data defined in XMLHttpRequest

I have a problem with my HTML and AngularJS code. Initially, I defined the list in my controller which worked fine: <li ng-repeat="a in idmasVesselstableList"><a>{{a.table_name}}</a></li> And here is how I set up the controller: ...

How to Use JavaScript Function to Rotate an Entire Webpage

For my final project in a web design class, we were tasked with creating a website that showcases our skills. I've completed the assignment and now I want to add some interesting features to make it stand out. I'm interested in using -webkit-tra ...

Ways to close jQuery Tools Overlay with a click, regardless of its location

I have integrated the Overlay effect from jQuery Tools to my website, with the "Minimum Setup" option. However, I noticed that in order to close it, the user has to specifically target a small circle in the upper right corner which can affect usability. It ...

Having issues with my script in Node.js where I am getting a TypeError when trying to make a https request. How can I properly

I am attempting to execute a curl request using node.js curl \ -H 'Authorization: ABC XYZ' \ 'https://api.wit.ai/message?q=Test' (Authorization has been replaced) This is the node.js code I tried: var https = require(" ...

Guide to summing the values in an input box with TypeScript

https://i.stack.imgur.com/ezzVQ.png I am trying to calculate the total value of apple, orange, and mango and display it. Below is the code I have attempted: <div class="row col-12 " ngModelGroup="cntMap"> <div class="form-group col-6"> ...

Encountering issues while trying to establish a connection to MongoDB through JavaScript

I have developed a code for seamlessly integrating various social networking logins with nodejs. Below is my server.js file: // include the necessary tools var express = require('express'); var app = express(); var port = process.env ...

Is fetch a viable alternative to AJAX?

Is it possible to achieve the same functionalities in Fetch as you can with traditional AJAX? I am currently facing an issue with a basic login authentication setup using Express. My goal is to provide feedback to the user without refreshing the page - dis ...

Comparing Products: Enhance Your Selection with Jquery to Add or Remove Items

I am looking to incorporate a "product compare feature" into the product list on my website. I am curious about how I can create a Query String URL from the product list page using jQuery, like the example below. The generated compare URL should follow th ...

Issue with Browsersync causing task to malfunction in Gulp 4

Gulp Local v4.0.2, CLI v2.3.0 Browsersync v2.26.13 gulpfile.js: 'use strict' const gulp = require('gulp') const concat = require('gulp-concat') const babel = require('gulp-babel') const uglify ...

How to display a "data not available" notification in AngularJS ngTable plugin tables when the data response array is void of content

I need to implement a no data message in my ngTable table when the response data array is empty. Currently, I have the following code: <tr ng-repeat="row in $data"> <td data-title="'name'" filter="{name: 'text& ...

Tips for pulling out a specific section of text from a string using various values in JavaScript

I have a block of text containing a mix of emails, phone numbers, and URLs that I need to extract individually. I attempted to use a substring method in JavaScript to achieve this, but I seem to be encountering some challenges. Below is a snippet of the ...

Ensure that the JSON object exists before saving it to local storage

[ { "id": 1, "title": "my First Item", "body": "" }, { "id": 2, "title": "my Second Item", "body": "" }, { "id": 3, "title": "my Third Item", "body": "" } ] Do ...