Solved

Jquery.form plugin submit onchange - problem

Posted on 2013-06-10
4
474 Views
Last Modified: 2013-06-11
Hello experts.
I want to use jquery.form plugin.
The problem i have is that i need to fire the ajax - submit on file select but i can't.
Here is my code
$(document).ready(function () {
 $("#instruc").on("change", ".filefield", function (e) {
     e.preventDefault();
     var myform = $(this).parent('form');
     $(myform).ajaxForm({
        dataType: 'json',
        url: 'myactionpage.cfc',
        beforeSubmit: validate,
        beforeSend: function () {},
        uploadProgress: function (event, position, total, percentComplete) {},
        complete: function (response) {}
    }, "json");
  }
 )
});

Open in new window

0
Comment
Question by:Panos
  • 2
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
Ishaan Rawat earned 500 total points
ID: 39236683
Try these.. one of these should work....
sorry for two answers but I am confused in a little thing..
Comment if any of the two works,,,,,

$(document).ready(function () {
 $("#instruc").on("change", ".filefield", function (e) {
     e.preventDefault();
     var myform = $(this).parent('form');
     myform.ajaxForm({
        dataType: 'json',
        url: 'myactionpage.cfc',
        beforeSubmit: validate,
        beforeSend: function () {},
        uploadProgress: function (event, position, total, percentComplete) {},
        complete: function (response) {}
    }, "json");
  });
});

Open in new window


OR

$(document).ready(function () {
 $("#instruc").on("change", ".filefield", function (e) {
     e.preventDefault();
     var myform = this.parent('form');
     myform.ajaxForm({
        dataType: 'json',
        url: 'myactionpage.cfc',
        beforeSubmit: validate,
        beforeSend: function () {},
        uploadProgress: function (event, position, total, percentComplete) {},
        complete: function (response) {}
    }, "json");
  });
});

Open in new window

0
 
LVL 2

Author Comment

by:Panos
ID: 39236930
Hi.
None of the two is working. I changed
$(myform).ajaxForm({
to
$(myform).ajaxSubmit({

Now it is working. I don't know what the differences between ajaxForm and ajaxSubmit are
0
 
LVL 10

Expert Comment

by:Ishaan Rawat
ID: 39237032
oo man its a big difference...

you should have specified...
0
 
LVL 2

Author Comment

by:Panos
ID: 39237266
I have the same code without the on change event ( it is working submiting the form with a button). It is working with ajaxForm.  In this case it is not.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HTTPS jquery doesn't work 9 70
Using jQuery to set a DIV attribute on page load 9 41
Question about JQuery and asp.net 3 30
jQuery Sticky Menu 24 34
Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question