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

后端 未结 3 875
甜味超标
甜味超标 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:14

    if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
    
    //Since your making php do the validation, there would be two cases,
    //the first case is that the php script is not echoing any thing on success, and 
    //the other case is that its echoing the error massages which will be assignedxmhttp.responseText
    //so we need to check that xmlhttp.resposeText has been asigned a value.
    
       if(xmlhttp.resposeText){
           document.getElementById(displayContainers_id).innerHTML=xmlhttp.responseText;
       }
    }
    

提交回复
热议问题