开发者

Load ajax data NOT in a div or other element

first of all, sorry for my bad english, I speak spanish. Well, I need some help in this case:

I made a microsoft excel POI report using java, this report is in a servlet that I call when do a clic in a href, por example:

<a href="ServeletReport">Report</a>

Until here, all ok, but I need to call this report using an event (it could be .load()) from jQuery, but this event only works assigning the data result to a div or other element. I not need assign the result to any element because my report is generated and open through in excel, if I assign it to a div, in this div appears rare simbols.

I need too add a loading imagen until my report is ready and opened.

I have a bad code, please I need some help.开发者_运维问答

$("#mylink").click(function(){
    $("#contenidoo").empty().html('<img src="images/loading-icon.gif"/>');
    $("#result").load("ServletReport");
});

I not need to put the result in a div $("#result"), I dont need to put the result in any place, I want to do clic and wait until my report is generated but viewing the loading image.


use the jquery .ajax function instead of .load: http://api.jquery.com/jQuery.ajax/


Use jQuery ajax() or get()

http://api.jquery.com/jQuery.ajax/

http://api.jquery.com/jQuery.get/


You can use the .get method to fire an HTTP GET request to the server, and use a callback function to do something once it has completed:

$("#mylink").click(function() {
    $("#contenidoo").empty().html('<img src="images/loading-icon.gif"/>');
    $.get("ServletReport", function() {
        $("#contenidoo").empty(); //Remove the image you appended above
    });
});


I found this very useful:

$("#mylink").click(function() {     
  $("#contenidoo").empty().html('<img src="images/loading-icon.gif"/>');     
    $.get("ServletReport", function() {        
     $("#contenidoo").empty(); //Remove the image you appended above     
  }); 
}); 

But I dont want to put the result in any place, and using the method above the reslult of my servlet (my excel doc) is not opened. I think its lacking some little thing. I hope your help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜