There is an important concept that should be noted here. When you add an event handler function that will be executed when a certain event is triggered, the value that the return event handler function does not actually go anywhere and nothing is passed. Event listeners are created to call event handler functions in an unknown place in the future, but typical script execution is completely linear and occurs in the order of the commands in the script - so itβs best to determine the functionality of your application in such a way that you perform certain actions like this only when certain events occur.
It looks like in your question above, you define one event handler to listen to when the form is submitted at the initial stage, so I will take this as the initial event that will fire everything. Here's how I can describe the feed process you are describing:
//wrap the form element in jQuery and cache it so we don't work to re-select it var $myform = $('
An example of this work on JSFiddle:
http://jsfiddle.net/Admiral/uweLe/
I would recommend reading the jQuery .on() method to get an idea of ββthe current event binding methods - this should fix the situation a bit.
http://api.jquery.com/on/
Good luck
source share