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 778895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:50:25+00:00 2026-05-14T19:50:25+00:00

Is it possible to post, say like a value in a textbox, to 2

  • 0

Is it possible to post, say like a value in a textbox, to 2 different ajax forms that are on the same page? It doesn’t have to be at the same time?

What I’m trying to do is this: I have a search page that searches for customers and displays them on a paged grid. Users can specify up to 5 parameters (5 textboxes) to narrow the search.

On the same page I have an export option. Well since I want all the customers for the search and not just the paged data I need a way to post back to the server for this option passing the same parameters used in the grid.

I’m using a ViewModel which would be nice if I can pass that back to the server rather than the individual search fields that are backed by the view model.

Thanks,
rodchar

  • 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-05-14T19:50:25+00:00Added an answer on May 14, 2026 at 7:50 pm

    Since you’re doing AJAX requests, we can safely assume that JS is allowed 😉

    Thus, use jQuery (or another JS library) to perform the AJAX postbacks, and just post to different urls.

    function postTo(url) {
        $.post(
            url,
            $('#theForm').serialize(),
            function(returnData) {
                // do this on success
            }
        );
    }
    

    Then, just hook up two different calls to this method to your submit links/buttons:

    $(function() {
        $('#searchButton').click(function() {
            postTo('/search/');
        });
    
        $('#exportButton').click(function() {
            postTo('/export/');
        });
    });
    

    EDIT in response to follow-up questions in comments:

    Q1) How can the controller parse $('#theForm').serialize() to a ViewModel object?

    A1) This is all part of the ASP.NET MVC model binding, and has nothing to do with the jQuery code. all .serialize() does with the form is to line up its names and values in a querystring-like format, so that data on the JSON object will end up something like 'textbox1=first value&textbox2=second value' etc for all form values. This works the same way as a regular POST request, so ASP.NET MVC doesn’t need to handle it any differently than a regular, non-AJAX request.

    Q2) Can the controller return entity object and can the callback read it?

    A2) You can serialize most objects to JSON using return Json(...) in your controller, but returning and entity object (which I assume is then from Entity Framework) is not recommended. It is much better to have a data transfer object (DTO) that only has the necessary properties.
    As for the callback, the ASP.NET MVC model binders can recognize any object as long as the input data is correctly formatted.

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

Sidebar

Related Questions

Possible Duplicate: JavaScript post request like a form submit I have a value calculated
Let say that I have the form below: <form action=sendMessage.php method=post> <label>Subject</label><input type=text></input> <label>Message</label><input
lets'say i have a form, with like this : <form name=frmMail method=POST action=save.do dojoType=dijit.form.Form
Say I have the following form that's in classic asp: <form name=impdata id=impdata method=POST
Possible Duplicate: Read Post Data submitted to ASP.Net Form I have a google checkout
Possible Duplicate: how to get GET and POST variables with JQuery? I have the
can anybody post the simplest possible example for django-ajax-selects ? Just one model with
One possible solution could be simple HTTP get or post request, but that wouldn't
Let's say that I have a file (file1.php) with a simple form with the
Lets say I have 2 tables: blog_posts and categories. Each blog post belongs to

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.