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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:14:18+00:00 2026-05-31T12:14:18+00:00

I am trying to make an ajax sending data in JSON from a partial

  • 0

I am trying to make an ajax sending data in JSON from a partial view. I get a System.ArgumentException: Invalid JSON primitive: undefined.
When I evaluate the object in a browser data contains an int and two strings. Can anyone tell me what I am doing wrong?

Partial View

@model FTD.Models.FTDAccountExtended
@using (Html.BeginForm()) {
<fieldset>
<legend>Update Policy Number</legend>
@Html.HiddenFor(m => m.account.ftd_accountsid)
@Html.HiddenFor(m => m.OldPolicyNumber)
@Html.TextBoxFor(m => m.account.ftd_policyno)
<input type="button" value="update" id="update" />
</fieldset>
}

<script type="text/javascript">
 $(document).ready(function () {
     $("#update").click(function () {
         var myUrl = '@Url.Content("~/")' + '/Maintenance/UpdatePolicyNumber';
         var data = [{ 'ClientNumber': parseInt($("#account_ftd_accountsid").val()), 'OldPolicyNumber': $("#OldPolicyNumber").val(), 'NewPolicyNumber': $("#account_ftd_policyno").val()}];
         $.ajax({
             url: myUrl,
             type: 'POST',
             data: data,
             contentType: 'application/json; charset=utf-8',
             success: function (data) {
                 alert(data.message);
             },
             error: function (errMsg) {
                 alert("Error", errMsg);
             }
         });
     });
 });

The controller method is

public ActionResult UpdatePolicyNumber(int ClientNumber, string OldPolicyNumber, string NewPolicyNumber)
{
    var message = string.Format("UpdatePolicyNumber CN:{0} OP:{1} NP:{2}", ClientNumber, OldPolicyNumber, NewPolicyNumber);
    if (_log.IsDebugEnabled)
        _log.Debug(message);
    if (!string.IsNullOrEmpty(NewPolicyNumber) && ClientNumber > 0)
    {
        _entities = new CloseFTD_Entities();
        _entities.UpdatePolicyNumber(ClientNumber, OldPolicyNumber, NewPolicyNumber, User.Identity.Name);

     }
     return Json
        (
           new
           {
               message = message
           },
           JsonRequestBehavior.AllowGet
         );
}
  • 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-31T12:14:19+00:00Added an answer on May 31, 2026 at 12:14 pm

    I would just try posting the the data as a java script object (as Marc mentioned above)
    and remove the content type attribute.

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

Sidebar

Related Questions

I'm trying to make an ajax-request to vimeo to get data from an vimeo
I'm trying to make an ajax call to grab session data to insert into
i'm trying to make a ajax update in prototype with some values from a
I am trying to make an ajax call using $.get() where I want to
I trying to make my first AJAX with JSON call using jQuery and CodeIgniter.
I am trying to make an ajax json callback using a .net application. So
I'm trying to make an AJAX GET request, but I simply cannot get it
Alright, I'm trying to make an AJAX Chat system that polls the chat database
I am trying to make a ajax call to other domain locally from my
I am trying to make an AJAX call from several domains to a single

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.