This script basically serializes a form and do get request on an api and retrieves json response. Received response can be modified by adding additional parameters via said form and serialized and is send to api and so forth. Right now every time i press submit only the last element shows up on the screen. I tried append functionality but it creates duplicate of the same set items instead of refreshing the items on the page. I believe it is a enclosure issue that may be trivial but i am not well versed in jquery and java script in general.
<script>
$(document).ready(function() {
var APISOURCE = '../api/software/?format=json'
$('#filterform').on('submit',function(e){
e.preventDefault();
var query = $('#filterform').serialize();
console.log(query);
$.ajax({
datatype: 'json',
url: APISOURCE,
query: query,
success: function(data){
console.log(data.results[0]);
$.each(data.results, function(i,results){
content = '<p>' + results.developer + '</p>';
content += '<br/>';
//$(content).empty("#softwarelist").appendTo("#softwarelist");
$("#softwarelist").html(content);
});
}/* response processing function ends */
});/* ajax function ends */
});
});
</script>
...'`
– par Dec 12 '13 at 08:33