jquery - Adding extra input stops javascript from working -
i trying edit javascript code, have no experience javascript.
i have html form, , trying add input it:
<form method="post" action="php/subscribe.php" name="subscribeform" id="subscribeform"> <input type="text" name="email" placeholder="enter email address notified" id="subemail" /> <input type="text" name="personname" placeholder="enter name" id="personname" /> <input type="submit" name="send" value="notify me" id="subsubmit" class="btn2" /> </form> <!-- subscribe message --> <div id="mesaj"></div> <!-- subscribe message --> </div>
the form subsequently pushes data php file. however, theme using features following javascript file:
jquery(document).ready(function(){ $('#subscribeform').submit(function(){ var action = $(this).attr('action'); $("#mesaj").slideup(750,function() { $('#mesaj').hide(); $('#subsubmit') .after('') .attr('disabled','disabled'); $.post(action, { email: $('#subemail').val() personname: $('#personname').val() // stops file working }, function(data){ document.getelementbyid('mesaj').innerhtml = data; $('#mesaj').slidedown('slow'); $('#subscribeform img.subscribe-loader').fadeout('slow',function(){$(this).remove()}); $('#subsubmit').removeattr('disabled'); if(data.match('success') != null) $('#subscribeform').slideup('slow'); } ); }); return false; });
originally theme came 1 input on form email. however, when try add personname
input both form , javascript file, stops javascript working. instead of php rendering inside main page, redirected blank php page echo
s success message.
like said earlier extremely inexperienced in javascript appreciated.
looks missing comma there:
$.post(action, { email: $('#subemail').val(), <--- comma here personname: $('#personname').val() // stops file working },
the javascript inside curlybrackets { ... }
(including brackets) known object. if have seen json formatted data before, should familiar you. syntax key , value colon separating them, , commas separating key-value pairs.
Comments
Post a Comment