Disable Submit Button Based on Ajax response

后端 未结 2 1451
萌比男神i
萌比男神i 2021-01-28 09:17

Ok in summary what I am trying to do is disable a submit button based on an ajax call which is checking my database to see if data exists under a certain date.

At presen

2条回答
  •  孤独总比滥情好
    2021-01-28 10:03

    Ok I figured it out. It transpires for whatever reason (Still cant find out where from) I was getting a newline on the returned ajax code and so albeit it was only blank space the if statement could not match the phrase I had asked it to check.

    By using $.trim (found in jQuery 'If' statement string comparison not working) I removed the blank space and it all fired into life.

    The new code now looks like this.

    if ($.trim(xmlhttp.responseText) == "WARNING!! - PREVIOUS RECORDS FOUND") document.getElementById('FRINSUB').disabled = true;
    

提交回复
热议问题