soumyajyoti soumyajyoti - 1 year ago 69
jQuery Question

Jquery Ajax Call throws undefined error

I am trying to send two variables to php using a Jquery Ajax call. The call works if async is set to false, but fails when it is true. The code also also works when only one variable is input using the form (basically get the response of input missing), however, when both the inputs are given, the code returns an undefined error. Can I get some suggestion please. Struck for quite some time. Here is my Jquery code -

$( document ).ready(function() {
url: "login.php",
type: "POST",
async: true,
data: {
"username": $("#username").val(),
"login_password": $("#login_password").val()

success: function(response){
$("#loginErrMsg").html() = response;
error : function (ts) {


If you want to assign something to html you have to put it between brackets.