如何在.Load JQuery调用中明确地发出GET请求?

时间:2022-12-04 17:49:34

I'm trying to load a view inside a JQueryUI Dialog.

我正在尝试在JQueryUI对话框中加载视图。

For that I'm using the solution proposed here:

为此我正在使用此处提出的解决方案:

https://*.com/a/11365246/1354478

https://*.com/a/11365246/1354478

<script type="text/javascript">
    $(function(){
        $(".popupLinks").click(function (e) {
            var url = this.href;
            var dialog = $("#dialog");
            if ($("#dialog").length == 0) {
                dialog = $('<div id="dialog" style="display:hidden"></div>').appendTo('body');
            }
            dialog.load(
                url,
                {}, // omit this param object to issue a GET request instead a POST request, otherwise you may provide post parameters within the object
                function (responseText, textStatus, XMLHttpRequest) {
                    dialog.dialog({                       
                        close: function (event, ui) {                            
                            dialog.remove();
                        },
                        modal: true,                            
                         width: 460, resizable: false
                    });
                }
            );           
            return false;           
        });
    });
    </script>

But Nothing was coming out, when I checked the Console the app was doing a POST request to my app instead of a Get. The Get DO need parameters to be executed, how can I specify it that I need a GET not a POST.

但是什么都没有出来,当我检查控制台时,应用程序正在对我的应用程序执行POST请求而不是Get。 Get DO需要执行参数,如何指定我需要GET而不是POST。

1 个解决方案

#1


1  

you need to remove empty object declaration in

你需要删除空对象声明

dialog.load(url, {}, functio...

dialog.load(url,{},functio ...

it should look like:

它应该看起来像:

dialog.load(url, functio...

dialog.load(url,functio ...

as is stated in documentation

正如文件中所述

#1


1  

you need to remove empty object declaration in

你需要删除空对象声明

dialog.load(url, {}, functio...

dialog.load(url,{},functio ...

it should look like:

它应该看起来像:

dialog.load(url, functio...

dialog.load(url,functio ...

as is stated in documentation

正如文件中所述