How can I get jQuery to perform a synchronous, rather than asynchronous, Ajax request?

后端 未结 14 2323
暗喜
暗喜 2020-11-21 05:07

I have a JavaScript widget which provides standard extension points. One of them is the beforecreate function. It should return false to prevent an

14条回答
  •  醉酒成梦
    2020-11-21 05:59

    function getURL(url){
        return $.ajax({
            type: "GET",
            url: url,
            cache: false,
            async: false
        }).responseText;
    }
    
    
    //example use
    var msg=getURL("message.php");
    alert(msg);
    

提交回复
热议问题