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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:12:17+00:00 2026-05-25T12:12:17+00:00

I have the following ajax function on my view in a ASP.NET MVC3 website.

  • 0

I have the following ajax function on my view in a ASP.NET MVC3 website. This function is called from a list in the top of the page, and it works great. But I need another value from the querystring, that needs to be passed to the controller function. How Do i achieve this ?

jQuery function

   function ShowDeals(itemNo) {
    //get the vendor



    var dialogDIV = $('<div></div>');
    $.ajax(
        {
            url: '/Deal/Index',
            type: "POST",
            data: ({ toets: itemNo }),
            dataType:'html',
            success: function (result) {
                $(dialogDIV).html(result);
                $(dialogDIV).dialog({
                    position : [,100],
                    error: function (req, status, error) {
                        alert(error);
                    }
                });
            },
            error: function (req, status, error) {
                alert(error);
            }
        })
        return false;
    }   

Controller Action

public ActionResult Index(int toets,string vendorNo)
    {
        string temp = toets.ToString();
        string tempdd = Request.QueryString["vendorNo"];
        //return Content("1212121212");
        return PartialView();
    }

The toets parameter is passed from the ajax function, but I now need the vendorNo that is in the Querystring.

Thanks

EDIT : I know I can add a javascript function to get the value from the querystring, but is that the best way to do this ?

  • 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-25T12:12:17+00:00Added an answer on May 25, 2026 at 12:12 pm

    You can pass that in the same way you pass in your toets param:

    var vendor = $("#TheElementThatHoldsYourVendor").text();
    $.ajax(
    {
        url: '/Deal/Index',
        type: "POST",
        data: ({ toets: itemNo, vendorNo: vendor }),
        ....
    });
    

    And then you’d have it as the second parameter, you don’t have to access the QueryString to fetch it.

    EDIT
    To fetch a url parameter using javascript, you could use this method (from here)

    function getUrlVars()
    {
        var vars = [], hash;
        var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
        for(var i = 0; i < hashes.length; i++)
        {
            hash = hashes[i].split('=');
            vars.push(hash[0]);
            vars[hash[0]] = hash[1];
        }
        return vars;
    }
    

    And then call it like this:

    $.ajax({
        ...
        data: { toets: itemNo, vendorNo: getUrlVars()['vendorNo'] }
        ...
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following function in my asp.net MVC view: $(function() { $('#datepicker').datepicker({ changeMonth: true,
I have the following function that is pulling data from a database. The ajax
I have the following AJAX call: $('#FonykerUsernameRegister').blur(function(){ if($(this).val().length > 2) { alert($(this).val()); $.ajax({ url:
I have this following view which I get data from a model and thereafter
I have the following simple jquery snippet $(document).ready(function () { $.ajax({ url:myjson.json, dataType: 'json',
I have the following code that works on Firefox and Chrome $("#adicionarItem").click(function(){ $.ajax({ type:
The problem is the following. We have lots of ajax call via $.ajax function.
I have the following restful api ajax call: $.ajax({ type: POST, url: https://website.com/a/login, data:
I have the following HTML structure being returned from an AJAX request... <th scope=col
I am using ASP.NET MVC with jQuery. I have the following MVC Action that

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.