简体   繁体   中英

ajax post not working without alert message

i have a problem with ajax post function. Ajax function doesn't working without alert message. If add alert message, div content will be refresh and working my code.

I have a mv3 application. And post form data to this javascript function. Like that:

    function Add_Definition() {
        var data = $.extend({ call: "Add_Definition", url: "/Definition/Definition", type: "post", dataType: "html", data: $("#definition_form").serialize() }, data);
        Load(ajaxrequest(data));
    }


    function Load(val) {
        if (val == true) {
            var data = $.extend({ call: "Load", render: $("#render"), url: '@Url.Action("Definition", "Definition")', type: "get", dataType: "html", data: { "groupid": '@Request.QueryString["groupid"].ToString()'} }, data);
            ajaxrequest(data);
        }
    }

My ajax javascript function is below.

function ajaxrequest(param) { var result = true;

 //alert("hi there"); $.ajax({ type: param.type, url: param.url, data: param.data, dataType: param.dataType, success: function (result) { $(param.render).empty(); $(param.render).html(result); result = true; }, error: function (request, status, error) { result= false; } }); return result; } 

If remove // char from javascript code, it will not work, (need refresh page), if have a alert message, content will be refresh with load function.

How is error?

您也可以像

var divElem = $('#yourdivid').load('@Url.Action("Definition", "Definition")');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM