javascript - PJAX with Laravel getting error notice on form submission -


i've got pjax working fine in instances, when submitting form, i'm getting odd error message in console:

uncaught typeerror: cannot read property 'tagname' of undefined

i've tracked down line 123 in pjax.js, is:

 function handlesubmit(event, container, options) {     options = optionsfor(container, options)      var form = event.currenttarget      if (form.tagname.touppercase() !== 'form') //error occurs here         throw "$.pjax.submit requires form element"      var defaults = {         type: form.method.touppercase(),         url: form.action,         container: $(form).attr('data-pjax'),         target: form     } 

the code still seems fire correctly, i'd clean errors.

so, added console.log(form) before see happening, , here's got:

undefined uncaught typeerror: cannot read property 'tagname' of undefined <form method="post" ... 

looks must firing method handlesubmit() twice, once blank data , once form, can't figure out why. here's fire pjax:

$(document).on('submit', 'form[data-pjax]', function(event) {   $.pjax.submit(event, '#pjax-body'); }) 

edit: here's form looks (using blade)

{!! form::open( ['url'=>['users/changestatus'], 'data-pjax']) !!} {!! csrf_field() !!} <input type="hidden" name="id" value="{{ $user->id}}"> <input type="hidden" name="status" value="{{ $user->status }}"> <button type="submit" >update</i></button> {!! form::close() !!}: 

i figured out.

i submitting form twice: once through button, , once through ajax i'd setup before refactoring use pjax. comes down stupid oversight


Comments