title: jQuery Ajax to PHP MySQL - Cross Domain Internal Server Erro (500)
body: <p>I have a jQuery ajax call to update my database using a php script.</p>
  
  <p>This is the call I make:</p>
  
  <pre><code>$.ajax({
          url: "update.php",
          type: 'POST',
          dataType: 'jsonp',
          data: {key1: value1, key2: value2},
          cache: false,
          error: function() {
              $("#failUpload").removeClass("hide");
          },
          success: function(data) {
              $("#succesUpload").removeClass("hide");
                      setTimeout(function() {
                          $("#succesUpload").addClass("hide");
                      }, 5000);
          }
     });
  </code></pre>
  
  <p>PHP Update part:</p>
  
  <pre><code>$key1 = $_POST["key1"];
  $key2 = $_POST["key2"];
  
  $con=mysqli_connect("localhost","username","password","dbname");
  
  if (mysqli_connect_errno()) {
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  
  $sql = "UPDATE TabelName SET ". $key2 ." ='". $key1 ."' WHERE id=1";
  
  if ($result = mysqli_query($con, $sql)) {
      $resultArray = array();
      $tempArray = array();
  
      while ($row = $result-&gt;fetch_object()) {
          $tempArray = $row;
          array_push($resultArray, $tempArray);
      }
  
  }
  mysqli_close($con);
  </code></pre>
  
  <p>The database updates and it works but in the console.log I receive this error message: <code>POST http://domainname.com/file.php?callback=jQuery2110765103816287592_1432976576289 500 (Internal Server Error)</code>
  When I open this I find this:</p>
  
  <pre><code>_.ajaxTransport.Y.cors.a.crossDomain.send @ jquery.js:26
  </code></pre>
  
  <p>I already searched and found about Cross Domain call stuff and you have to use jsonp etc but it didn't work out. Thx!</p>