javascript - jQuery - IF ELSE - Not reading any variables -
problem:
update: have found not returned data post. literally every if
else
statement disregards variables almost entirely.
i have tried extremely simple verify statement above.
when code below executed, nothing happens. added consol.log()
in before if statement ( in place of alert ) make sure getting data dom , is.
html
<input type='submit' name='confirm' class='button' value='confirm' > <input type='submit' name='cancel' class='button' value='cancel' >
js
$( '.button' ).on( 'click' , function() { var btnname = $( ).attr( 'name' ) ; var cancel = "cancel" ; var confirm = "confirm" ; alert( btnname + cancel + confirm ) ; if ( btnname == cancel ) { //some function here . . } else if ( btnname == confirm ) { //some function here . . }
edit if run code below, alert cancel
... fudge.
$( '.button' ).on( 'click' , function() { var btnname = $( '.button' ).attr( 'name' ) ; if ( btnname == "cancel" ) { alert( 'cancel' ) ; } else if ( btnname == "confirm" ) { alert( 'confirm' ) ; }
not matter click, functions in if
statement don't run. weird part is, when hits alert( btnname + cancel + confirm ) ;
data alerted in browser accurate, in, if click name='confirm'
alert output looks confirmcancelconfirm
...
i assume have error:
function( data ) { if ( returneddata == "company added" ) { //right here $( '#navadmin' ).click() ; } else { alert( data ) ; } }
it should
function( data ) { if ( data == "company added" ) { $( '#navadmin' ).click() ; } else { alert( data ) ; } }
Comments
Post a Comment