Posts

Showing posts with the label post

How to use C++ /WinRT HttpRequestMessage with Custom POST Body and HttpFormUrlEncodedContent (UWP App)

How to use C++ /WinRT HttpRequestMessage with Custom POST Body and HttpFormUrlEncodedContent (UWP App) In Windows 10, 1803 it is possible to call the WinRT from standard conforming C++. The C++ /CX language extensions are not required anymore. I already know how to send a post Request to a Server using the HttpRequestMessage Class: #pragma comment(lib, "windowsapp") #include "pch.h" #include "winrt/Windows.Web.Http.Filters.h" #include "winrt/Windows.Web.Http.Headers.h" #include <winrt/Windows.Foundation.h> #include <winrt/Windows.Foundation.Collections.h> #include <string_view> using namespace winrt; using namespace Windows::Foundation; using namespace Windows::Web::Http; using namespace Windows::Web::Http::Filters; using namespace Windows::Web::Http::Headers; using namespace Windows::Foundation::Collections; using namespace std::literals; using namespace std; IAsyncAction HttpClientExample(Uri uri) { HttpBaseProtocolFilter ...

Ajax success function with python: odd behavior

Ajax success function with python: odd behavior I found an odd behavior when trying to use data on the browser-side, which is sent by a python script client-side. The ajax call is: $.ajax({ async: true, type: "POST", url: "/path/cgi-bin/pyscript.py", data: JSON.stringify(my_array), dataType: "html", success : function(data) { document.getElementById("ajaxAnchor").innerHTML = data + "Some random string to test display" } }); } I wanted to send back to data the result of a print() in the python script, but this only works in an unusually specific case. For the printed data to be sent back, there must first exist a print() executed with an n at the end. data print() print() n print("This line won't be sent to browser but is necessary n") print("This text will be sent back") And it's not just about adding the line break, because the following example won't work: ...

Post data from client to Node server

Post data from client to Node server I can post data to node server though i can't access the data in my app.get route. orders.hbs (ajax): $.post( "/show_items", { o_id: result } ); app.js: app.post ('/show_items', function(req,res){ var order_num = req.body.o_id; }); app.get('/orders',authenticationMiddleware(), function(request, response){ console.log(order_num); ... } The problem is that in my app.get i can't access the $order_num variable. How can i access the variable and use it? 2 Answers 2 I want to know the use-case before answering. As you sent the data in POST-API, it should ideally be available/used by all middlewares (functions) defined to POST-API. @Yoni: You are trying to use info passed in POST API (under property req.body.order_num) in altogether different GET API. But if you want to access it anyway then solution shared by @Bostrot works fine. ...