Skip to content
Advertisement

Send Javascript array to PHP using Ajax (can’t echo out the array from PHP)

I’ve a form with a simple button in it. When clicking on the button the function delete_data() is called. This function fills an array with data. I would like to send this array to PHP with Ajax.

Problem: When using the event.preventDefault(); as you can see in my JavaScript code, the success alert messages is displayed (“OK”) but i don’t obtain the echo from my php script.

Could you correct my code bellow or tell me what is wrong? Thanks a lot!

HTML CODE

JavaScript

JavaScript CODE

JavaScript

PHP CODE

JavaScript

Advertisement

Answer

It’s logic that you don’t see the echo. Add a parameter to the success function like this:

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