为我的对象设置空值

时间:2012-01-23 16:09:06

标签: javascript

var JsonClient = Titanium.Network.createHTTPClient();

// API Url to call
var url = "";

JsonClient.open("POST", url, true);

JsonClient.onload = function () {
    // after processing the response
    json = null;
}
JsonClient.onerror = function (e) {
    actAllergyInd.hide();
    Ti.UI.createAlertDialog({
        title: 'Error',
        message: JsonClient.statusText,
        buttonNames: ['Ok']
    }).show();
};
}

//setting Request Header
JsonClient.setRequestHeader("Content-type", "application/json");
JsonClient.send(data);
JsonClient = null;

我想将我的JsonClient对象设置为null以及我得到null的Json response我是以正确的方式做的吗?

1 个答案:

答案 0 :(得分:1)

您可以使用delete运算符:

https://developer.mozilla.org/en/JavaScript/Reference/Operators/delete

delete JsonClient;