How to make an HTTP request from HTML? [duplicate] - javascript

This question already has answers here:
HTTP GET request in JavaScript?
(31 answers)
Closed 6 years ago.
I want to send an async HTTP request from the HTML, parse a response, and update an HTML page respectively. Is there a way to do it without using AJAX or any other third-party library?
I'd like to find the most basic way to do this.
Since libraries can do it, it should be possible without them too.
Worth saying, that I'm a mobile developer who checks web development for a couple of days.
UPDATE 1
I didn't have to call AJAX a "third-party library". My bad.
UPDATE 2
Thanks everybody who responded. What I've learned: the only way to do what I wanted is AJAX, in particular, XMLHttpRequest.

There is no way without JS. The most basic way is to either use the new fetch() API, or good old XMLHttpRequest() link

Related

Can you make a email-send system without Php? [duplicate]

This question already has answers here:
What is the difference between client-side and server-side programming?
(3 answers)
Closed 1 year ago.
I really don't understand how Php works and i am a little nervous, i don't like the idea of using more application for a email-send system. Is there anyway to do that without php, only in javascript/html/css? Can someone explain how this works or if is there something i need to know?
I tried to find on google, but i didn't find anything useful. Thanks in advance! :)
Sending mail requires a program to run on a server, and PHP is a language that can talk to a server. You can't send an email using just HTML, CSS and Javascript.

How to proxy http requests with plain javascript? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I'm writing a bot with plain javascript that sends requests to a certain website without node.js or dependencies like jquery. I want to send every requests through a proxy, but I can't figure out how to do that with vanilla js.
I don't know where to even start. I've read the xhr documentation and found nothing about proxies. Google yielded nothing too.
Thanks!
There are two broad categories of proxy server (that we need to care about for the purposes of this question).
Ones designed to be set up as an HTTP proxy for a client. These require that the client be configured to use the proxy (for example, see this university's guide to using their proxy). You cannot use client-side JavaScript to make a browser use this kind of proxy.
Ones which present as a regular HTTP server but which determine what response to make by making an HTTP request to a different server (as opposed to reading a static file or executing a CGI program). To use these: Just make an HTTP request to a URL hosted by the proxy server.

how to pass form values from html page to java object? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am in the starting stages of a web project which uses Java to connect to a server and retrieve the data from the server. I have created the initial html page which accepts some values from the user like employee id etc. which has to stored in a Java object and sent to the server.
How do I store the data into a Java Object from my html page? I have searched through a lot of sites but did not find anything satisfactory.
Any guidance would be welcome.
Thanks in advance.
You need to write Java REST API, and make a post call from your form, along with your formdata.
You need something handling HTTP requests. In Java you have few options and I recomend to read about Servlets(easiest, lightweight solution) or for example REST Webservices, SpringMVC but those are more complex solutions.
You will alse need at least servlet container like Tomcat to deploy your web application with servlets.
I would recommend to use a Web API framework, like Dropwizard.
http://www.dropwizard.io/1.0.5/docs/getting-started.html
There are alternatives, but reading this page should give you an impression of how a REST API works. To explain the basis; you create a java API that handles all HTTP calls from your front end application, which contains html/css/js. you post data to your Java API. The framework helps you to receive this calls, which you can then process using your backend (Java) logic.
you need to read about the following topics:
1: making post request to your server with the formdata.
2: reading the request parameters from HttpServletRequest, since it would contain your formdata.
3: Finally you need to assign the values read from the request, to your object.

How to create ajax request in AngularJs? [duplicate]

This question already has answers here:
What is the best practice for making an AJAX call in Angular.js?
(4 answers)
Closed 7 years ago.
I just want to send requests and get responses using AngularJs, but I haven't tried anything yet.
The $http-service is what you are looking for. It comes with preconfigured get and post methods to make easy requests, but you can also configure your requests as you wish.
You can use $http service or restangular for that. https://github.com/mgonto/restangular

Why is there a for(;;); preamble in facebooks JSON responses? [duplicate]

This question already has answers here:
Why does Google prepend while(1); to their JSON responses?
(8 answers)
Closed 8 years ago.
Why is there a for(;;); preamble in facebooks JSON responses?
See this StackOverflow post: How to restrict JSON access?
In particular this comment within that thread: for/while loops in JSON responses
Basically this is used so that attackers can't get the URL and include it on their page and have JavaScript now put the variables on the page because as soon as the request has been serviced the browser will go into an infinite loop not allowing other JavaScrip access to said variables which would potentially allow attackers to use your browser to get information that is meant to stay private.
Basically this just runs an infinite loop when parsed. That way, the user's browser freezes (eventually providing a popup allowing the user to stop the script), and the data is never actually read. Hope this makes sense!

Categories