NEET JASSI
NEET JASSI

Reputation: 85

jQuery AJAX request not being sent

I have two variables, current_min and current_max. I am setting their values but AJAX is not working.

var current_min = $('#min').val();
var current_max = $('#max').val();

//alert(current_min+current_max);
$.ajax({
    type: "POST",
    url: "v.php",
    data: "city=" + current_min,
    success: function(response) {
        alert(response);
        $('#result').html(response);
    }
});

I have checked the console and the error showing is this:

no element found
no element found

Upvotes: 0

Views: 57

Answers (1)

ashkufaraz
ashkufaraz

Reputation: 5297

Correct Way to Send Data With AJAX Is data: { name: "John", location: "Boston" }

So try like this

$.ajax({
    type: "POST",
    url: "v.php",
    data: {"city": current_min},
    success: function(response) {
        alert(response);
        $('#result').html(response);
    }
});

Upvotes: 1

Related Questions