Skip to content
Advertisement

What could be wrong with this request in AJAX and PHP?

I’m trying to call a PHP page passing parameters with AJAX. I can see that the page is called, but the $_REQUEST doesn’t take any parameters. If anyone can help me, I’d appreciate it. Thanks!

My AJAX is that:

JavaScript

In the PHP Page, I have this.

JavaScript

Always the answer is failure. Thank you!

Advertisement

Answer

1- change your data format in ajax request from data:’cod_evento=’ + href, to data : {code_evento:href}

2 – change your php echo from echo “alert(‘OK’);” to echo “OK”; and same for else clause

Recommended 1 – change $_REQUEST to $_POST 2 – change alert(‘data:’+ data) to console.log(data)

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