PHP(via IIS 7.5) is not receiving post via ajax

Asked

Viewed 164 times

0

I have an AJAX request made to the own page where the AJAX routine has been set.

Configuring the request with POST method is not being sent. Switching to GET is successfully sent.

I think this may be some configuration in IIS or PHP installation. Both are installed locally and a few days ago changes were made to them due to errors that were later discovered to be in the database, but I do not know exactly what was changed.

This is the code I’m using:

$.ajax({
    type: "POST",
    async: true,
    url: "nova_pg_novo_grupo.php?t=" + d.getTime(),
    contentType: "application/json",
    data: {
        "comando" : "salvarGrupo",
        "inputNomeGrupo" : $("#inputNomeGrupo").val()
    },
    cache: false,
    success: function(data) {
       alert(data);
        $("#divSuccess").html("Grupo salvo!");
    },
    error: function (xhr, ajaxOptions, thrownError) {
        alert(xhr.status);
        alert(thrownError);
    }
});

Nor was it necessary to declare the Contenttype and now not declaring presents Ternal Server Error (500).

Edit: I think I found the problem, php is not displaying errors... Thank you

  • How data is handled in PHP?

  • Not sending or not receiving? You can check in the browser’s Dev Tools and see if the request has been made. Knowing this you can find the error in the correct location (JS or PHP or IIS)

  • Through the code as I passed, on Alert is returned all html content, skipping if PHP, switching to get, the Alert returns that the sent variables have been taken. But previously, with the same version of javascript, everything happened right, I wrote my codes in the same way, which leads me to think that PHP or IIS had their settings changed (I didn’t change and I don’t know how to configure them), in php, to test I put this code: if ($_POST['command']){ echo "post"; } if ($_GET['command']){ echo "get"; } Sorry for the bad edit...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.