Reputation: 189
i use this function for a tag click this work fine and my code return true but data variable is false .why??
$('#AddProvince').click(function () {
var url = '@Url.Action("SetProvinceList")';
var id = $('#Province').val();
var result=false;
$.post(url, { PID: id }, function (data) {
if (data == true) {
var p = "<tr class='tRow'> <td class='tbody'>" + $('#Province option:selected').text() + "</td></tr>";
$('#tblPRovince tr:last').after(p);
}
});
});
Upvotes: 1
Views: 215
Reputation: 28548
response from call is always a string, you can try:
if(data)
or
if(data === 'true')
Upvotes: 1
Reputation: 365
this is because data is a String, and not a boolean, just use
data == 'true'
Upvotes: 3