i want to store json data in a textarea temporally then i can use it later. in text.js got bellow function:
function getList(pageNo, pageLimit, id, queryData){
var $container = $('#js-skp-table'),
$pageContainer = $('#js-skp-pager'),
$pageNum = $('#js-skp-num'),
$tmpl = $('#js-skp-item');
$.ajax({
url : '/test/url/'+ id,
data : $.extend({}, queryData, {page: pageNo+1, limit: pageLimit}),
type : 'GET',
cache :false,
dataType: 'json',
success: function(data){
var items = [];
if(data.data && data.data.length > 0){
$.each(data.data, function(index){
items.push( $tmpl.tmpl(data.data[index])[0]);
});
var tempStr = JSON.stringify(searchDataArr);
tempStr=tempStr.replace(/\"/g,"'");
$('#myTextarea').text(tempStr);
console.log('testarea:'+$('#myTextarea').val()); // got output
$container.empty().append(items);
$pageNum.text(data.data.length);
$pageContainer.empty().pagination(data.total, {
items_per_page : pageLimit,
current_page : pageNo,
callback : function(page, component){
window.location.hash = '#page=' + page;
getList(page, pageLimit, id, queryData);
}
});
}
},
});
}
in text.html
getList(0, 10, id, queryData);
console.log('testarea:'+$('#myTextarea').val()); // output nothing.
updated to
getList(0,50,seckill_id).complete(function() {
console.log('testarea:'+$('#myTextarea').val());
});
now, my question is: how come first console.log got output value, but second not? then, new error come out: Uncaught TypeError: Cannot read property 'complete' of undefined