I want to give a condition if value of id=type_investor is 1 or 6 to send mail using different controller.
here is my full code :
function (isConfirm) {
if (!isConfirm) return;
$.ajax({
url: "{{URL::to("cpanel/deposit-withdraw-list/approve-depositwithdraw")}}",
type: "POST",
data: {id: fund_id,key: refdc_data},
dataType: "html",
success: function () {
$.ajax({
url: "{{URL::to("cpanel/deposit-withdraw-list/approve-tostatement")}}",
type: "POST",
data: {id: fund_id},
dataType: "html"});
if ($('#type_investor').val == 1){
$.ajax({
url: "{{URL::to("cpanel/deposit-withdraw-list/sendmail-deposit")}}",
type: "POST",
dataType: "html"});
}else{
$.ajax({
url: "{{URL::to("cpanel/deposit-withdraw-list/sendmail-withdraw")}}",
type: "POST",
dataType: "html"});
}
swal("Approved!", "It was succesfully Approved!", "success");
$('#refdc').val('');
window.location.href = "{{URL::to("cpanel/deposit-withdraw-list/")}}";
},
error: function (xhr, ajaxOptions, thrownError) {
swal("Error Approved!", "Please try again", "error");
window.location.href = "{{URL::to("cpanel/deposit-withdraw-list/")}}";
}
});
And I think, maybe the point of problem is in this code
if ($('#type_investor').val == 1){
$.ajax({
url: "{{URL::to("cpanel/deposit-withdraw-list/sendmail-deposit")}}",
type: "POST",
dataType: "html"});
}else{
$.ajax({
url: "{{URL::to("cpanel/deposit-withdraw-list/sendmail-withdraw")}}",
type: "POST",
dataType: "html"});
}
because if condition value of id="type_investor"
is 1
, it use controller in else condition.
it always using else condition. I dont know where is actually my problem.