0

I am currently trying to set up a request such that when a button is clicked, it runs uses ajax to call a php script to change stuff in the database. but I am having issues where I keep getting an error with the

this is the ajax request. anytime I run this. I get an error stating "Error 500 (internal server error)"

$.ajax({
            url:"./scripts/test.php", //the page containing php script
            type: "POST", //request type,
            data: {registration: "success"},
            success:function(result){
        
            console.log(result.abc);
            },
            error: function(req, textStatus, errorThrown) {
            alert('Ooops, something happened: ' + textStatus + ' ' +errorThrown);
            }
                 });

my php code:

<?php

echo "hello world";
?>

I dont know what could be causing this, but anytime I try this on my live website (or local) it doesnt want to work.

Imd15
  • 31
  • 6
  • 2
    Remove the space between `` and `php` here ` php` – Jay Blanchard Aug 25 '20 at 14:30
  • @JayBlanchard I fixed it, but that shouldnt be the issue since It doesnt even successfully send anything to the php file – Imd15 Aug 25 '20 at 14:34
  • 2
    Yes it does, otherwise you wouldn't be getting a 500 error which is a server-side error. – Jay Blanchard Aug 25 '20 at 14:38
  • 1
    Open the browser's developer tools (F12) and watch the request/response in the network tab of the developer tools when you trigger the AJAX call. Change `console.log(result.abc);` to `console.log(result);` – Jay Blanchard Aug 25 '20 at 14:47
  • 1
    Holy shit, my bad for being so dismissive haha. you're right it was the space. I thought i fixed it before. but I forgot to send it to my live server. youre a godsend. thank you – Imd15 Aug 25 '20 at 15:30

0 Answers0