Sample code for 30+ languages & platforms
JavaScript

Example: Http.QuickGetStr method

Demonstrates the QuickGetStr method.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat v11.4.0 or greater.
JavaScript
var http = new CkHttp();

// Keep the response body if there's an error.
http.KeepResponseBody = true;

// Send the HTTP GET and return the content in a string.
var str = http.QuickGetStr("https://www.chilkatsoft.com/helloWorld.json");
if (http.LastMethodSuccess == false) {
    if (http.LastStatus == 0) {
        // Communications error.  We did not get a response.
        console.log(http.LastErrorText);
    }
    else {
        console.log("Response status code: " + http.LastStatus);
        console.log("Response body error text:");
        console.log(http.LastResponseBody);
    }

    return;
}

console.log(str);
console.log("Success");