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

  • Home
  • SEARCH
  • 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 8426095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:27:15+00:00 2026-06-10T04:27:15+00:00

Hi all i have ajax where i have some data And a controller action

  • 0

Hi all i have ajax where i have some data And a controller action method …i need to send the data to the controller action method …when i am doing this it has null values in my controller method ,can any one correct me where am i doing worng…

       <script type="text/javascript">
    $(document).ready(function () {

        $("#butValidateForm").click(function () {               
            UpdateMethod();
        })
    });
    function UpdateMethod() {
        var s = document.getElementById("EmployeeID");
        var selecteditem1 = s.options[s.selectedIndex].value;

        var a = document.getElementById("FromStatusId");
        var selecteditem6 = a.options[a.selectedIndex].value;

        var data = '{"AssignTo":"' + selecteditem1 + '","Status":"' + selecteditem6 + '"}';
        alert(data);

        $.ajax({
            type: "POST",
            url: "/ViewBug/Update/",
            enctype: 'multipart/form-data',
            data: data,
            success: function () {
            }
        });
    }  

</script>

my contoller action method

          [HttpPost]
    public ActionResult Update(BugModel model, FormCollection form, string selecteditem1, string selecteditem6)
    {
        if (Session["CaptureData"] == null)
        {
        }
        else
        {
            model = (BugModel)Session["CaptureData"];
        }
        ViewBag.AssignTo = new SelectList(GetEmployee(), "EmployeeID", "EmployeeName");
        ViewBag.Status = new SelectList(GetFromStatus(), "FromStatusId", "FromStatus");
        using (SqlConnection conn = new SqlConnection(connString))
        {
            SqlCommand cmd = new SqlCommand("sp_history", conn);
            cmd.CommandType = CommandType.StoredProcedure;
            conn.Open();
            cmd.Parameters.Add("@Title", SqlDbType.VarChar).Value = model.Title;
            cmd.Parameters.Add("@FixedById", SqlDbType.VarChar).Value = model.LoginName;
            cmd.Parameters.Add("@AssignedId", SqlDbType.Int).Value = model.AssignTo;
            cmd.Parameters.Add("@Resolution", SqlDbType.VarChar).Value = model.Resolution;
            cmd.Parameters.Add("@FromStatus", SqlDbType.VarChar).Value =model.Status;
            string fileName = string.Empty;
            string StrFilePath = string.Empty;
            foreach (BugAttachment objList in model.ListFile)
            {
                if (string.IsNullOrEmpty(StrFilePath))
                {
                    fileName = objList.AttachmentName;
                    StrFilePath = objList.AttachmentUrl;
                }
                else
                {
                    fileName = fileName + "," + objList.AttachmentName;
                    StrFilePath = StrFilePath + "," + objList.AttachmentUrl;
                }
            }
            cmd.Parameters.Add("@AttachmentName", SqlDbType.VarChar).Value = fileName;
            cmd.Parameters.Add("@BugAttachmentUrl", SqlDbType.VarChar).Value = StrFilePath;
            cmd.Parameters.Add("@AttachedBy", SqlDbType.VarChar).Value = model.LoginName;
            cmd.ExecuteNonQuery();
            conn.Close();
        }
        return View("Edit");
    } 
  • 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-10T04:27:17+00:00Added an answer on June 10, 2026 at 4:27 am

    I ended up doing the following:

          <script type="text/javascript">
        $(document).ready(function () {
    
            $("#butValidateForm").click(function () {               
                UpdateMethod();
            })
        });
        function UpdateMethod() {
            var s = document.getElementById("EmployeeID");
            var selecteditem1 = s.options[s.selectedIndex].value;
    
            var a = document.getElementById("FromStatusId");
            var selecteditem6 = a.options[a.selectedIndex].value;
    
           // var data = '{AssignTo:' + selecteditem1 + '}';
           // alert(data);
            var AssignTo;
            var Title;
            Title=$("#Title").val();
            var FixedBy;
            FixedBy = $("#LoginName").val();
            var Resolution;
            Resolution = $("#Resolution").val();
            var Status;
            Status = $("#FromStatusId").val();
            $.ajax({
                type: "POST",
                url: "/ViewBug/Update/",
                enctype: 'multipart/form-data',
                data: {AssignTo:selecteditem1,Title:Title,FixedBy:FixedBy,Resolution:Resolution,Status:Status},
                success: function () {
                }
            });
        }
    
    
    
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this AJAX submission form written with the jQuery validation plugin. It all
I have a form[method=get] which has a number of checkboxes all have the same
I have the code as per below. This retrieves some data to use for
I have a View that gets some bits of data via Action methods that
I need to send a polling AJAX request to the server and send some
I have here an myAction function in some controller. And it has one class
I used to have a simple ajax that helped me take all items from
I have a strange error where my jquery ajax request doesn't submit all the
I need to execute an action of a controller when a user leave a
In an asp.net mvc3 view, I have a $.get() ajax call to a controller

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.