質問

Background

I am using spring MVC with hibernate

jquery Code snippet

$(document).ready(function() {
    $( "#dialog" ).dialog();
    $('#tableDiv').load('genCityInqGV.htm?type=0&number=1');
    $( "#dialog" ).dialog('close');
} );

In @Controller

    @RequestMapping(value = "/genCityInqGV", method = RequestMethod.GET)
public String genCityInqGV() {
    try {
        while(true){
            System.out.println("Print");
        }
    } catch (Exception ex) {
        log.error("Exception.." + ex);
    }

    return "gen/genCityInqGV";
}

In controller I write finite loop to check whether dialog functionality working or not ? but dialog still going to close. this means that following statement execute.

$( "#dialog" ).dialog('close');

after the following one

$('#tableDiv').load('genCityInqGV.htm?type=0&number=1');

when I check the screen the following statement still print

System.out.println("Print");

Even the process of load function in back-end still processing , so why dialog('close') statement execute.

Update me!

役に立ちましたか?

解決

What was your code like before using Spring MVC, because the principle should remain the same.

jquery load() loads asynchronously, so the next statement can very well be executed before the load is finished.

Maybe you can get around this using a callback after the load (perhaps this is what you did before?). Please take a look at How to load page synchronously using jQuery.

try:

$('#tableDiv').load('genCityInqGV.htm?type=0&number=1', function(){
    $( "#dialog" ).dialog('close');
});
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top