javascript - html is not consistent show on div -
hey have grid, grid have edit button. when click edit button call method , method have 3 new methods, 3 methods have ajax request controller , view , append in div. problem time show div html time show empty divs why behaviuor div empty please me should do..
this 3 divs
<div id="div1"></div> <div id="div2"></div> <div id="div3"></div>
this main function calling other functions
function main(url1, url2, url3) { func1(url1); func2(url2); func3(url3); }
all 3 functions
function func1(page) { $.ajax({ type: "post", url: page, data: $("#data").serialize(), datatype: "html", success: function (html) { $('#div1').empty(); $('#div1').append($.parsehtml(html)); }, error: function () { alert("error"); }, complete: function () { //complete } }); } function func2(page) { $.ajax({ type: "post", url: page, data: $("#data").serialize(), datatype: "html", success: function (html) { $('#div2').empty(); $('#div2').append($.parsehtml(html)); }, error: function () { alert("error"); }, complete: function () { //complete } }); } function func3(page) { $.ajax({ type: "post", url: page, data: $("#data").serialize(), datatype: "html", success: function (html) { $('#div3').empty(); $('#div3').append($.parsehtml(html)); }, error: function () { alert("error"); }, complete: function () { //complete } }); }
its better create 1 function not 3
function func(element , page) { $.ajax({ type: "post", url: page, data: $("#data").serialize(), datatype: "html", success: function (html) { $(element).empty(); $(element).append($.parsehtml(html)); }, error: function () { alert("error"); }, complete: function () { //complete } }); }
and use
function main(url1, url2, url3) { func('#div1',url1); func('#div2',url2); func('#div3',url3); }
finally ajax request
1- check url file connection
2- check data passed ajax
3- check data returned success function
Comments
Post a Comment