2012-08-10 2 views
2

나는 가능하지 않다고 알고 있지만 내 서버에는 이미지가 있고 $ .ajax 함수를 통해 내 jquery 모바일 앱에 다운로드하고 표시하고 싶습니다. 여기 있습니다 내가 사용하고있는 코드 :

$.ajax({ 
type: "GET", 
url: $url, 
dataType: "jpeg", 
async: true, 
timeout: 90000, 
success: function($data) 
    { 
console.log("success"); 

}, 
error: function() 
    { 
console.log("failure"); 
} 


}); 

나는 오류이 그것은 AJAX와 이미지를 다운로드하는 것은 의미가 없게 올바른 접근 방식

답변

0

인지 확실하지를 얻고있다.

<div id="example">Example</div> 
<script> 
    var url = 'http://lorempixel.com/output/abstract-q-c-64-48-8.jpg'; // URL of the image 
    $('#example').click(function() { 
    $('<img>') // create a new image element 
     .attr('src', url) // set src 
     .appendTo(this); 
    }); 
</script>​ 

근무 예 : http://jsfiddle.net/zrbRM/

당신은 아마 그냥 IMG element의의 src 속성을 설정해야합니다
관련 문제