I want to publish the data and display the HTTP response of the server in the browser, but I am stuck in the browser.

I want to publish the data and display the HTTP response sent by the server in the browser, but I am stuck in the browser. Nothing is displayed.

I checked the wired shark that the server is sending a json response, but nothing is displayed in the browser, and I want to get the body of the response and analyze it, and then display it to the user.

And is there any way to get the details of the form, and then wrap it on a variable and send it to the server

<!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $.post( "http://192.168.0.135:8080/uid", { "type" : "CREATE_ACCOUNT", "data" : '{ "hardwareID" : "SAM1234567890123", "name" : "Jain", "emailID" : " jain@gmail.com ", "password" : "dgbedbeifkfk" }' }, function(data,status) { alert("Data: " + data + "\nStatus: " + status); } ); }); }); </script> </head> <body> <button>Send an HTTP POST request to a page and get the result back</button> </body> </html> 
+4
source share
1 answer

To tell you your JSON is invalid, this is the correct version of your JSON:

 { "type": "CREATE_ACCOUNT", "data": { "hardwareID": "SAM1234567890123", "name": "Jain", "emailID": " jain@gmail.com ", "password": "dgbedbeifkfk" } } 

Delete the 'before the line {in your "data.

I highly recommend that you check your JSON through jsonLint.com before looking for other errors.

0
source

Source: https://habr.com/ru/post/1444287/


All Articles