How To Call Javascript In Ajax Response? IE: Close a form div upon success

后端 未结 3 878
甜味超标
甜味超标 2021-01-21 10:55

I have a form that when you submit it, it sends the data for validation to another php script via ajax. Validation errors are echo\'d back in a div in my form. A success messa

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-21 11:03

    Your AJAX call should have a "success" callback. It looks like you can simply call displayDiv() in that callback.

    Also note that the var divstyle = new String(); line is unnecessary. Strings are immutable in JavaScript, so you are creating an empty string object, which remains unreferenced in the following line. Simply declare the variable when you assign it from document.getElementById():

    var divstyle = document.getElementById("myForm").style.display;
    

提交回复
热议问题