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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:05:27+00:00 2026-06-07T12:05:27+00:00

I have an input <input type=button id=test value=test /> My action on the ‘Home’

  • 0

I have an input

<input type="button" id="test" value="test" />

My action on the ‘Home’ controller:

public ActionResult DataUsage(DateTime startDate, DateTime endDate, string userName)
{
  var data = FetchDataFromDB(startDate, endDate, uName);
  return PartialView("DataUsageChartViewPartial", data);
}

The div I want to load the result form DataUsage in

<div id="myChart"></div>

jQuery code

$(function() {
    $("#test").click(function () {
        $.ajax({
               url: '/Home/DataUsage',
               type: 'POST',
               data: { startDate: $('#startDate').val(), endDate: $('#endDate').val(), userName: $('#userName').val() },
               success: function (result) {
                   alert("success " +result);
              },
              error: function (err) {
                 alert("error "+err);
             }
            });
            return false;
        });
    }
 );

When I click the button I want the div(myChart) to be populated with the result from the action in the controller.
I’m not sure if my jQuery is correct as I keep getting an error and the breakpoint in my controller/action is never hit.
Can someone please tell me what I’m doing wrong and how to correct it

  • 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-07T12:05:28+00:00Added an answer on June 7, 2026 at 12:05 pm

    Maurice,

    I think it could well be a very simple case of not having the correct url being called. You should try using the helpers in mvc:

    url: '@Url.Action("DataUsage", "Home")'
    

    Also, you might want to decorate your action with HttpPost to ensure that it’s in step with your ajax type, i.e:

    [HttpPost]
    public ActionResult DataUsage(...)
    

    this should take you one step closer, if not solve the issue completely.

    The final step is to ensure that you have a div called ‘myChart’ inside your ‘calling’ view, then populate it as thus:

    <div id='myChart'></div>
    
    success: function (result) {
        $('#myChart').html(result);
    }
    

    hope this helps

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

Sidebar

Related Questions

I have the following code, which works fine: <input type=button name=btnHello value=Hello onclick=Test();/> and
<form id=search action=/search method=get autocomplete=off> <div> <input type=button name=test_button value=test /> </div> </form> <script>
I have this: $(document).ready(function() { $(input[type=button]).click(function () { $(#test).html(W3Schools); alert(Would submit: + $(this).siblings(input[type=text]).val()); $.ajax({
I have a button on a file test.php <?php $url=http://.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; ?> <input type=button name=btn
I have this code: <INPUT type=button value=Pre-Requisites onClick=window.open('pre_requisites.php','pre-requisites','width=670px,height=470px,left=0px,top=100px,screenX=0,screenY=100')> It is use to open a
I have some dynamic buttons that look like this: <input type=button name=button id=button value=Click
I have the following code: echo ' <td> <input type=button name=delete value=X onclick=clearSelection(this.form, '.$type.');this.form.submit();
I have created button 2 below: <input id=Button1 type=button value=Stop onclick=alert('hello world');/> <input id=Button2
I have form: <form method='post' action='script.php'> <textarea id='main' name='text'></textarea> <input type='hidden' name='id' value='1'> <input
I have 3 edittexts with input type as number and 1 button that say

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.