Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Jquery.form plugin submit onchange - problem

Posted on 2013-06-10
4
Medium Priority
?
481 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
Ishaan Rawat earned 2000 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

TCP/IP Network Protocol Cheat Sheet

TCP/IP is a set of network protocols which is best known for connecting the machines that make up the Internet. The truth is that TCP/IP is one of the oldest network protocols and its survival is mainly based on its simplicity and universality.

Question has a verified solution.

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

DOM Attributes and Properties treatment with jQuery 1.6 by Ivo Stoykov jQuery (http://jquery.com/) 1.6 introduces .prop() (http://api.jquery.com/prop/) and .removeProp() (http://api.jquery.com/removeProp/) methods which allow modifying or removi…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

688 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