javascript - ajax POST handler looping -


i'm trying setup basic ajax submit handler modify form (i'm writing lesson on csrf vulnerabilities), page keeps looping. here's example code i've been tinkering with, based off http://api.jquery.com/jquery.post/:

 <!doctype html>  <html>  <body>   <form id="hidden_form" target="blahblah.com"> </form>   <script>  //attach submit handler form  $( '#hidden_form' ).submit(function( event ) {        //stop form submitting       event.preventdefault();        //set new target form       var $form = $( ),         url = "http://192.168.101.250/mutillidae/index.php?page=add-to-your-blog.php&csrf-token=securityisdisabled&blog_entry=example+text&add-to-your-blog-php-submit-button=save+blog+entry"        //capture response nothing       var posting = $.post( url );  });  </script>   <script>       $( '#hidden_form' ).submit();  </script>   </body>  </html> 

when load file locally browser, tab label switches between /path/to/file.html , "connecting" fast, know request never gets sent out because have burp proxy intercepting traffic , it's not capturing anything.

so doing wrong? want ajax handler send post request url specified, never gets sent out

edit: i've changed second script call handler instead of actual form, there's still no traffic sent on wire?

calling .submit() directly on form element node not trigger submit event, instead, directly submits form bypassing event handlers. should instead call jquery form of method trigger event handler.

$( '#hidden_form' ).submit(); 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -