ajaxform - How to Get JSON Data from PHP Script using jQuery Ajax
one text
Solution:
You should set your content-type
header in your back-end response. (Content-Type Header)
Add header('Content-Type: application/json');
before echo
line in your php code, Or add dataType: 'JSON'
to your ajax
argument. (PHP header function)
And you should pay attention to @RiggsFolly's comment about sql injection:
SourceYour script is open to SQL Injection Attack. Even if you are escaping inputs, its not safe! You should alway use prepared parameterized statements in either the MYSQLI_ or PDO API's instead of concatenating user provided values into the query. Never trust ANY user input!