1
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;

I want to set my JsonClient object to null as well as the Json response which i am getting to null. Am i doing it in the right way?

1
  • Why do you care? JavaScript is memory-managed, you do not have to "free" stuff after you use it. Commented Jan 23, 2012 at 16:15

1 Answer 1

1

You could use the delete operator:

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

delete JsonClient;
Sign up to request clarification or add additional context in comments.

2 Comments

delete is not a function, it is an operator.
@Tomalak Thank you, I edited my answer. I did read it was an operator but yet I still put it as an function, silly me...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.