Clear ajax results on closing of fancybox

Clicking on the radio button, fancybox(modal) will open in that there is search input after typing keyword by pressing search icon calling function myFun() and geeting results to the variable ‘results’ and appedning that to div which have class’pane’.
Issue1: once get the results I am cloing the modal window if again I have clicked on radio button the modal window is showing with existing results, though I have made display:none in afterclose methos of fancybox.
Issue2: Once get the results of the keyword, if again searched the values are appending to the existing one.

<div><input type='radio' id="radioresults" />

<div class="abc-form">
<input type="text" value="" id="searchkey"/>
<div class="pane" style="display:none">
</div>

$('radioresults').fancybox(){


	afterclose:function(){$('pane').css('display', none'); $('searchkey').value('') }
}

function myFun(){
	$.ajax{

	type: GET;
	data: $('#searchkey').value();
	cache:false;		


	success:function(data){

		$('pane').css('display', 'block');

		var results = $('<div/>').addClass('myClass').html(data);

	
		}
		$('pane').append(results);
	}
}

This is not final code just on high level I had written.

To cancel an ajax query you can call the abort method on the ajax object

@felgall: After googled I found this solution abort method, but I am unable to implement that where should I need to keep it, if possible could you please incorporate that code in my code and I can able to understand.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.