F
F
foxgray2011-06-12 15:57:29
JavaScript
foxgray, 2011-06-12 15:57:29

POST HTTP request in JavaScript?

What are the ways to make an HTTP POST request in JS?
I want to write a plugin for firefox that would display my ISP account balance. In theory, everything is solved with a simple post request. I read about xmlhttprequest and the impossibility of cross-domain requests. Do all browser extensions (for example, Yandex.bar) use this kind of hack? Or is it all about the fact that the developers of such plugins have access to the server side and the ability to control the server response?

Answer the question

In order to leave comments, you need to log in

8 answer(s)
@
@resurtm, 2011-06-12
_

You can create an invisible form, set the necessary form attributes and submit it.
Specific implementation in Yii Framework: code.google.com/p/yii/source/browse/trunk/framework/web/js/source/jquery.yii.js (submitForm function).

N
NikoB, 2011-06-12
@NikoB

1. Jquery + Cross domain mod for jQuery (but only get requests can be sent this way)


2. Using a flash container as an intermediary
3. Using an invisible iframe as an intermediary
4. Using your server as an intermediary

@
@resurtm, 2011-06-12
_

And by the way, you also need to see if the POST action to receive data from CSRF is protected on the target server. If so, then nothing will work.

A
ArtemSmirnov, 2011-06-12
@ArtemSmirnov

Plugins have more powers and strictly speaking plugins may not even be in js

H
Homakov, 2011-06-15
@Homakov

you can, create an xhr component, set onload=function and go to battle. smirnov is right, powers are enough for cross dom req

D
Denis Turenko, 2011-06-15
@Dennion

Yes, I came across this side myself recently. Solved the problem like this
: 1. we hook the external js through the script tag, it calls the XML POST request to the php file on the same remote server data.js.php
2. data.js.php immediately displays the js action result code
var result=... ...;
and the JS function for managing this data is executed locally, since they are already local.
This is how I implemented the output of a showcase of goods from a remote server without unnecessary libraries in the affiliate module. You can see what happened (Affiliate block).

K
KAdot, 2011-06-16
@KAdot

Everything is much easier than it seems. Cross-domain requests are allowed from the Firefox XHR extension.

D
Denis Turenko, 2011-06-16
@Dennion

You can make a Windows Gadget (if Windows is installed), it will be very clear to show data on the desktop and huge rights are given there for execution and a lot of reference books on the language (JScript).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question