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?