最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Send post to URL using jshtml - Stack Overflow

programmeradmin1浏览0评论

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

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

Share Improve this question asked Mar 5, 2013 at 16:07 whdwhd 1,8611 gold badge22 silver badges55 bronze badges 1
  • 1 Take a look here it may help stackoverflow./questions/133925/… – Marcos Brigante Commented Mar 5, 2013 at 16:12
Add a ment  | 

4 Answers 4

Reset to default 2

If you consider jQuery to be JavaScript it sure is.

See here:

http://api.jquery./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 remend you get used to using jQuery.

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

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.

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./ajax/ajax_xmlhttprequest_send.asp

发布评论

评论列表(0)

  1. 暂无评论