I am getting data as "success" but when I am comparing it to print some result it is not going in if part rather it is executing else part.
As you can see in the image on the right-hand side I console log data which gives success
(on left side console page).
Again when i am comparing data with the exact same string "success" it is not printing "hello" rather it goes to the else part and prints "hellddo".
You Should Provide The Code Of Both Your PHP File & Your JS Code Instead Of The Image. So That Code Can Be Easily Copy Pasted And Executed Fast Instead Of Typing It Out.
Coming To A Solution, As @Swati Commented, Try Trimming The data Variable To Remove Any Whitespaces:
console.log(data.trim() == 'success')
And, To Fix The Problem On The PHP Side, You Should Just Check If You Accidently Typed
" success"
Instead Of "success"