mirror of
https://github.com/ariya/phantomjs.git
synced 2024-09-11 04:46:09 +03:00
20 lines
473 B
JavaScript
20 lines
473 B
JavaScript
// Example using HTTP POST operation
|
|
|
|
"use strict";
|
|
var page = require('webpage').create(),
|
|
server = 'http://ptsv2.com/t/phantomjs-toilet/post',
|
|
data = '{"universe": "expanding", "answer": 42}';
|
|
|
|
var headers = {
|
|
"Content-Type": "application/json"
|
|
}
|
|
|
|
page.open(server, 'post', data, headers, function (status) {
|
|
if (status !== 'success') {
|
|
console.log('Unable to post!');
|
|
} else {
|
|
console.log(page.content);
|
|
}
|
|
phantom.exit();
|
|
});
|