I am brand new to JQUERY and have the task of fixing an attachment upload script for one of our site.
I have a form that allows a user to upload certain file types as long as the file is 5MB or smaller. The page is using PHP, JQUERY, AJAX and JSON and is sending its information to our companies Salesforce.com (SFDC) CRM sysem to create a helpdesk CASE.
The way the form works is that when the user fills in the attachement field and then clicks submit it creates a hidden iframe and a hidden form. It clones the file input box, and clones the entire original form to the hidden form. The iframe is used to call a PHP file that check the files size and exntension. If correct it uploads the file into SFDC and then sends an email to our support group with a link to the file in SFDC along with the rest of the form information. After completing this processing it calls the .remove() function to clear the hidden iframe and form and returns itself to the original form where the submit button was clicked.
If the attachment file was of the right size and file extension then the original form successfully submits to SFDC and creates a CASE with the original forms details and a link to the attachement with in the SFDC CASE.
My problem is if the file is of the wrong extension or larger than 5 MB when it comes back to the original form all the jquery onchange events and the onclick events initalizes by the $(document).ready seem to now be unbond from the form because the onchange events for select lists and the click of the submit button no longer do anything.
My questions are...
1) Am I correct in thinking that the originial form has become unbound from the objects setup in the original $(document).ready call because of the calls to the .remove method for the hidden iframe and form?
2) Can I call $(document).ready again to rebind all the onchange events and onclick of the submit button event?
3) Is there a way to not have to re-execute the $(document).ready such that when the file size or extension is too large it gracefully exits and allows the original form to be corrected and resubmitted without reloading the form?
I have been sturggling with this for quick some time now and any tips would be appreciated.
John