0

How to load image via ajax and make it show in div?

$("<div />").load("#{load_image_path}/"+$(this).attr("data-id"), function(data) { //IN WHICH FORMAT IT MUST BE GIVEN?
    $(".la-anim-10").removeClass("la-animate");
    $(".fullscreen").css("background", "url('#{load_image_path(13)}')"); //HOW IT MUST BE WRITTEN HERE?
    $(".fullscreen").css("display", "block");
  });
CJRoman
  • 63
  • 1
  • 9
  • the page you're trying to load... do you need that to be a full query string or is just passing the id okay? does it need to be `/ID=123` or is just `/123` okay? also... `data` is your response... I wouldn't know how you should use it unless you tell me what kind of response you're expecting exactly. – gloomy.penguin Nov 11 '13 at 04:24
  • `#{load_image_path}/"+$(this).attr("data-id")` - this string makes full URL to controller (Rails syntax), like: http://localhost/welcome/loadimage/13 (13 is ID). – CJRoman Nov 11 '13 at 04:28
  • And I cannot guess, which responce I need. I can pass or image itself as binary data, or link to image – CJRoman Nov 11 '13 at 04:29
  • well... make sure the URL is correct and inside the function add `console.log(data)` and see what you're getting back (if anything). [this looks like a good example](http://stackoverflow.com/a/4338083/623952) of what you're trying to do... – gloomy.penguin Nov 11 '13 at 04:33

0 Answers0