object does not contains method or property

Mar 6, 2014 at 2:47 PM
hi,
i have this js code:
function WebClient() {

    DownloadString: function (path, callback){
        var wc = new System.Net.WebClient();
            
        var result = wc.DownloadString(path);
        if (typeof(callback) != "undefined")
        {
                callback(result);
        }
        return result;
    };

}
and when i use this class:
var w = new WebClient();
w.DownloadString("http://www.google.de/");
come error: object does not contains method or property
but all is correct?
Coordinator
Mar 6, 2014 at 3:30 PM
Hi furesoft,

You probably intended to define your function like this:
function WebClient() {
    this.DownloadString = function (path, callback) {
        var wc = new System.Net.WebClient();
        var result = wc.DownloadString(path);
        if (typeof(callback) != 'undefined') {
            callback(result);
        }
        return result;
    };
}
Cheers!