whd
whd

Reputation: 1861

Send post to URL using js/html

I'm trying to find if its possible to send POST to url using only html and javascript. According to this its not possible. Can anyone knowledgeable tell me is it possible ? and if it's how to do it? ad1 Without using jQuery

Upvotes: 3

Views: 4607

Answers (4)

Chris
Chris

Reputation: 943

As per the article, if the URL is not in the same origin, it is not possible. This is for security reasons.

If it's within the same origin (domain) then it is possible.

Pure JS (no frameworks) examples here: http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp

Upvotes: -1

Quentin
Quentin

Reputation: 943579

I'm trying to find if its possible to send POST to url using only html and javascript.

Yes

According to this its not possible.

No. The Same Origin Policy, in general, prevents you reading data from different origins. Pre-flight checks sometimes prevent you sending data, but there are several ways to circumvent the policy.

and if it's how to do it? ad1 Without using jQuery

XMLHttpRequest and jQuery.ajax are well documented.

Upvotes: 2

thitemple
thitemple

Reputation: 6059

If you really want to you can use XMLHttpRequest. All major browsers support it.

Upvotes: 2

user1781710
user1781710

Reputation:

If you consider jQuery to be JavaScript it sure is.

See here:

http://api.jquery.com/jQuery.post/

If you're going to be doing a lot of this sort of thing in your development in the future, I'd highly recommend you get used to using jQuery.

Upvotes: 2

Related Questions