I was to set size of image which I will recive from ajax. Problem is I dont know how to fire function exacly after success.
My resize function (which work when I fire by myself from chrome dev console after ajax, but won't go automaticly after ajax ):
function resizePromiseImage(x) {
x.success(function() {
var wW = window.innerWidth,
app = $('#app'),
picH = 0,
ratio = 0,
picW = app.find('img').width();
if( wW < picW ){
app.find('img').css({
'width':wW
});
}
});
}
My ajax function (which gives me image just like I want to):
function ajax(){
return $.ajax({
url: 'http://blabla.bla/bla.php',
success: function(data){
if(data){
var url = 'http://blabla.bla/bla/'+data+'.jpg',
app = $('#app');
app.html('"');
}else{
$('#wrap').append('pusto');
}
}
});
}
and executing code:
// get a promise:
var promise = ajax();
// give a promise to other function:
resizePromiseImage(promise);