Skip to content
Advertisement

php ajax insert shows blank response but no error

I am simply inserting a demo data by ajax form to database. The ajax shows no error but shows blank response when i use console.log(response);.

Php code-

JavaScript

ajax code-

JavaScript

mysql —

JavaScript

Advertisement

Answer

You’re echoing a script block in the response, which makes no sense in an AJAX context.

Also you’re not echoing any content in anything except the pure success case, and you’re checking for the wrong variable in $_POST – your AJAX code only sends “f_name” to the server, nothing else.

You also have a typo in your SQL query – :f_name should not in in quote marks within the SQL string.

This should give you more feedback:

JavaScript

If it still doesn’t output anything after that, do some more debugging – check your browser’s Console and Network tools to see if the request is even succeeding.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement