Search code examples
javascriptphpjqueryxmlhttprequest

Any one know why this XHR request is not posting? Error 500


I set up this XMLHttpRequest(); and it is showing error 500.

<?php 
SESSION_start();

$balance = $_POST['public'];
$_SESSION['test'] = $balance;

    var ne = 4;
  var params = 'public='+ne;
    var xhr = new XMLHttpRequest();


    xhr.open("POST", "url.php");
    xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xhr.send(params);


Solution

  • Your XHR works fine. Your error is returned by the server running url.php.

    A common issue is a bad .htaccess configuration, or your server is not ready and configured properly to interpret PHP.

    Did you test browsing url.php normally? If POST requests are not being received, I don't see how GET requests would work either.