0

So this is a little weird, when my if statement is false the console log shows that pass never gets added to the myData Object, but if set to true then it does. The if statement is checking to see on submit of the form if pass field is NOT DISABLED then post the pass field along with the others otherwise dont post pass.

$(document).on('submit', '#editaccount', function(event) {
  event.preventDefault();

  myData = {
    contactname: $('input[name=contactname]').val(),
    business: $('input[name=business]').val(),
    email: $('input[name=email]').val(),
    code: $('input[name=code]').val(),
    phone: $('input[name=phone]').val(),
    priceband: $('input[name=priceband]').val(),
    address: $('input[name=address]').val(),
    active: $('input[name=active]').val(),
    mon: $('input[name=mon]').val(),
    tue: $('input[name=tue]').val(),
    wed: $('input[name=wed]').val(),
    thu: $('input[name=thu]').val(),
    fri: $('input[name=fri]').val(),
    sat: $('input[name=sat]').val(),
    sund: $('input[name=sund]').val(),
    adminname: $('input[name=adminname]').val(),
    accountid: $('input[name=accountid]').val(),
    isadmin: $('input[name=isadmin]').val(),
  };

  var isDisabled = $('input[name=pass]').is(':disabled');

  if (isDisabled == false) {
    myData.pass = $('input[name=pass]').val();
  }

  $.ajax({
    url: 'php/editaccount.php',
    type: "POST",
    data: myData,
    success: function(data) {   
      if ($('input[name=isadmin]').val() == 1) {
        $('input[name=accountsearch]').val($('input[name=email]').val());
        $('input[name=accountsearch]').submit();
      } else {
        $('input[name=accountsearch]').val($('input[name=business]').val());
        $('input[name=accountsearch]').submit();
      }
      alert(data);
    }
  });
  console.log(myData);
});
Shiladitya
  • 12,003
  • 15
  • 25
  • 38
  • working fine for me. – Abhishekh Gupta Jun 07 '15 at 15:26
  • Like I said before this works in console but not on actual Ajax query. –  Jun 07 '15 at 15:27
  • You might have said it in your previous questions ([here](http://stackoverflow.com/q/30694173/859640) or [here](http://stackoverflow.com/q/30542196/859640)), but you didn't say it in this question. – John S Jun 07 '15 at 16:13

0 Answers0