javascript - submitting form with PJAX -


im using pjax in web project, , when submit form, pjax handling it, related stuff coming in , replacing in pjax container, after default action happening- form getting submitted in traditional way , entire page loading again

form html here

<form  class="form_class"><input type="text" name="search" id="search_query" class="basic_input" value="" /><button onclick="this.form.submit();" >find</button></form> 

here pjax code form invoking

$(document).on('submit', '.form_class', function(event) {           $.pjax.submit(event, '#container_id');         }); 

it works- the default form submission happens, want pjax way, dont want complete page reload(the traditional submission)

just use event object cancel default submission behavior:

$(document).on('submit', '.form_class', function(event) {     event.preventdefault(); // stop default submit behavior      $.pjax.submit(event, '#container_id'); }); 

if not work perhaps cancelling late. try:

$(document.body).on('submit', '.form_class', function(event) {     event.preventdefault(); // stop default submit behavior when bubbles <body>      $.pjax.submit(event, '#container_id'); }); 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -