Skip to content

@macton /test_http.js forked from macton/test_http.js
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Examples of using jsdb http_utils.js Stream.GET and Stream.POST extensions
load('http_utils.js');
writeln('-------- Example 0 ---------');
var search_topic = 'dancing cats';
var google_api = new Stream('net://ajax.googleapis.com:80');
function show_result( data )
{
writeln('Google found ' + data.responseData.cursor.resultCount + ' pages about ' + search_topic );
}
google_api.GET( '/ajax/services/search/web', { v: '1.0', q: search_topic }, show_result, 'json' );
google_api.close();
writeln('-------- Example 1 ---------');
var posttestserver = new Stream('net://posttestserver.com:80');
var get_test = posttestserver.GET('/data/2010/10/17/18.40.351320933049');
var post_test = posttestserver.POST('/post.php', { sample_text : 'hello, world!', sample_array: [ 0, 1, 2, 3, 4 ] } );
writeln( get_test );
writeln( post_test );
posttestserver.close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.