Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9125985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:55:54+00:00 2026-06-17T06:55:54+00:00

I am using the JQuery Form plug-in to send forms via Ajax. I cobbled

  • 0

I am using the JQuery Form plug-in to send forms via Ajax. I cobbled together the code from various places and everything works perfectly, except one thing.

Upon success the data from the PHP processing file gets output to a <div> (i.e. the ‘message sent’ response). The ID of that <div> is currently set within the function. What I want to do is to be able to set that ID outside of the function so it is more easily re-usable, but I can’t for the life of me work out how to pass that ID into the function. Because:

  1. I cannot set any arguments in the success: section, I can only name the function.

  2. I can’t seem to be able to pass an argument any other way, i.e. I cannot add an extra argument to the success function, i.e. writeOutput(data,divID), defining divID elsewhere.

Here’s the relevant code:

$(formOne).ajaxForm({
    beforeSubmit: function() {
        return $(formOne).validate({
            // validation rules
        }).form();
    },
    beforeSend: function() {
        // beforeSend actions
    },
    success: writeOutput
});

function writeOutput(data) {

    var $out = $('#output');

    if (typeof data == 'object' && data.nodeType)
        data = elementToString(data.documentElement, true);
    else if (typeof data == 'object')
        data = objToString(data);

    $out.append('<div>'+ data +'</div>');
}

So how can I define the ID (which is currently #output) outside of the writeOutput() function?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:55:55+00:00Added an answer on June 17, 2026 at 6:55 am

    Not sure if this works and not a direct answer,

    For “I cannot set any arguments in the success: section”, you could do something like:

    $(formOne).ajaxForm({
        beforeSubmit: function() {
            return $(formOne).validate({
                // validation rules
            }).form();
        },
        beforeSend: function() {
            // beforeSend actions
        },    
        success: writeOutput,
        context: { extra_arg: 'some_value' }
    });
    
    function writeOutput(data) {
        var extra_var_val = this.extra_var; //the extra argument
        var $out = $('#output');
    
        if (typeof data == 'object' && data.nodeType)
            data = elementToString(data.documentElement, true);
        else if (typeof data == 'object')
            data = objToString(data);
    
        $out.append('<div>'+ data +'</div>');
    }
    

    Whatever is passed into ‘context’ becomes the context of the callback function. Hope it works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

a quick question. I am using the jQuery.forms.js plug-in. I have a form that
I am using jQuery Form Plugin to upload my files via AJAX and I
i need help with this. I'am using JQuery's Dynamic Form plug-in, it duplicates my
I send asynchronous call using jQuery form plugin and in the case of success
I am using the jquery form plugin which uses jquery ajax to do most
I'm using Jquery Ajax Form to upload files, which works well in Chrome and
Using the jQuery Validation plug-in for the following form: <form id=information method=post action=#> <fieldset>
I'm using the following JQUERY Plug-in to upload ideas: http://valums.com/ajax-upload/ For some reason I'm
I'm using jQuery Form ( http://jquery.malsup.com/form/ ) to get send data to a form
I tried to make an contact form via AJAX with jQuery and Validation Engine

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.