문제

I'm trying to write a Gnome program in Javascript. HTTP requests are done with a library called Soup, and GET requests start with something like:

msg = Soup.Message.new('GET', self.url) ...

Examples for GET requests are all over the net, but how to do a POST request?

도움이 되었습니까?

해결책

Based on our chat conversation, this code will work:

msg = Soup.Message.new('POST', self.url);
var POSTparams = 'try=this';
msg.set_request ('application/x-www-form-urlencoded', 2, POSTparams, POSTparams.length);

The syntax seems to be:

msg.set_request('MIME type', (2), 'params=here', 'params=here'.length);

This answer was also based on the following:

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top