javascript - Jquery Ajax method POST does not work on remote server -


i've been working on website quite time, done on localhost. after making login form work decided upload hosting.
issue callback functions of ajax don't seem work if use method: post
if change post get work...

ajax code:

$.ajax({       method: 'post',       url: "php/login.php",       data: { username: val_username, password: val_password },       success: function(response) {         if (response == 0) {           location.reload();         } else {           alert("wrong username or password. error #"+response);         }       }     }); 

login.php

<?php  session_start();  require "../php_includes/mysql.php";  // create connection $conn = new mysqli($db_server, $db_user, $db_pass, $db_name); // check connection if ($conn->connect_error) {   die("connection failed: " . $conn->connect_error); }  // escape parameters prevent sql injection $username = mysqli_real_escape_string($conn, $_post['username']); $password = mysqli_real_escape_string($conn, $_post['password']);  $sql = "select * korisnici username='$username'"; $sql_result = $conn->query($sql);  if ($sql_result->num_rows > 0) {     $row = $sql_result->fetch_assoc();     if (password_verify($password, $row["password"])) {         $_session["loggedin"] = true;         $_session["userid"] = $row["id"];         echo 0;     } else echo 2; } else echo 1;  ?> 

i have checked file locations, no issue there, since works if change method get.

i tried changing datatypes in ajax, tried adding headers php file i've found searching around stackoverflow, nothing helps...

make sure have same version of php on hosting server (at least php 5.5 since you're using password_verify() >= php 5.5).


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -