我正在尝试使用从ajax调用中每行的第一列计算的数据来更新每一行的每第三列。我无法获得$ .map或$ .each行来更新每行的每第三列以及$ .post请求生成的数据。
const clearUrl = url => url.replace(/^data:image\/\w+;base64,/, '');
const downloadImage = (name, content, type) => {
var link = document.createElement('a');
link.style = 'position: fixed; left -10000px;';
link.href = `data:application/octet-stream;base64,${encodeURIComponent(content)}`;
link.download = /\.\w+/.test(name) ? name : `${name}.${type}`;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
['png', 'jpg', 'gif'].forEach(type => {
var download = document.querySelector(`#${type}`);
download.addEventListener('click', function() {
var img = document.querySelector('#img');
downloadImage('myImage', clearUrl(img.src), type);
});
});
答案 0 :(得分:0)
我能够使用此代码使其工作并执行我想要的操作:
var relationsToSeller = [];
$('tr td:first-child').find('a').each(function(index, value) {
var portfolioArray = $(this).attr('href').split('&id=');
//Ajax request to get username's relation to seller and append text
$(this).parent().next().next().find('a').load( 'http://localhost/public/?r=matchTable/relationtoseller', { portfolioId: portfolioArray[1] });
});