I have the following Ajax call which send form data to a page and finds specific response.
$.ajax({
url: $("form[name='MainForm']").attr('action'),
data: $("form[name='MainForm']").serialize()+'&btnupdateprice.x=0&btnupdateprice.y=0',
type: 'POST',
cache: false,
success: function(response) {
errors = $(response).find("#listOfErrorsSpan");
result2= $(response).find(".colors_pricebox:eq(0)");
$(".colors_pricebox:eq(0)").replaceWith(
'<table width="100%" cellspacing="0" cellpadding="0" border="0" class="colors_pricebox">' + result2.html() + '</table>');
$('#listOfErrorsSpan').replaceWith(
'<span id="listOfErrorsSpan">' + errors.html() + '</span>');
}
});
Each time the page call this page via Ajax it loads about 74k of data. I do not have a specific programming question but instead would like to know if there is a way or ways to limit the possibility of any leaks or.... in this case, I extract out two areas of the loaded page and store it in variable "error" and variable "result2".
Do I need to do something like destroy, detach or otherwise "remove" the unused data in the response. Is it stored somewhere. Each reload via Ajax does it get overwritten or take up new space. Do or should I need to destroy the error and result 2 variables once they are used since they are no longer needed? Or perhaps I would or should not use the variables to store the result and just do this directly as shown below?
Sorry if I am not making much sense. Not very familiar with this. I would just like to know if there is anything I should be concerned with with regards to leaks. Thanks for any feedback.
$(".colors_pricebox:eq(0)").replaceWith(
'<table width="100%" cellspacing="0" cellpadding="0" border="0" class="colors_pricebox">' + $(response).find(".colors_pricebox:eq(0)") + '</table>');
$('#listOfErrorsSpan').replaceWith(
'<span id="listOfErrorsSpan">' + $(response).find("#listOfErrorsSpan").html() + '</span>');