[SOLVED] How to Refresh page in AJAX | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

[SOLVED] How to Refresh page in AJAX

If(data ==“Yes”){ location.reload(); }else { alert(“username/password is incorrect ”); } When the data is true Ajax not refresh the page ???

24th May 2020, 1:53 PM
Ahmad Al-Zreqat
Ahmad Al-Zreqat - avatar
5 Answers
+ 2
Ahmad Al-Zreqat There maybe many possibilities of this problem. 1 - are you getting Yes in response. 2 - if yes then what type of response you are getting like as an object or as a String. 3 - if you are getting as an object then data == "Yes" will not work. Except these points I am not getting any problem because location.reload() always works. To Debug this you need to check response type and you can also print on console inside if condition.
24th May 2020, 4:05 PM
A͢J
A͢J - avatar
+ 2
Ahmad Al-Zreqat Try to print data == "Yes" and Check what you get true or false
24th May 2020, 2:43 PM
A͢J
A͢J - avatar
+ 1
Ahmad Al-Zreqat Are you getting Yes in response?
24th May 2020, 1:57 PM
A͢J
A͢J - avatar
0
yes when i input faild data the alert is shown but when im input right data no refresh no alert so the proplem why no action when i input right data and i use event.preventDefault(); but when i removed the ajax not work correctly AJ #Infinity Love
24th May 2020, 2:36 PM
Ahmad Al-Zreqat
Ahmad Al-Zreqat - avatar
0
when im checked network code status with true value is given 302 Found (no refresh page ,no errors) with wrong value 200 OK (error shown)
24th May 2020, 3:54 PM
Ahmad Al-Zreqat
Ahmad Al-Zreqat - avatar