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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:34:05+00:00 2026-05-26T09:34:05+00:00

In my html I have <h2>Title goes here</h2> @using (Html.BeginForm(Action, Controller, FormMethod.Post, new {

  • 0

In my html I have

<h2>Title goes here</h2>

    @using (Html.BeginForm("Action", "Controller", FormMethod.Post, new { id = "myFormID" })) {
        <input type="text" id="testinput" name="testinput" />
        <input type="text" id="testinput2" name="testinput2" />

        <input type="button" value="click me" onclick="submitForm();" />
    }

in my js I have

function submitForm() { 

    dataString = $("#myFormID").serialize();

    alert(dataString);

    $.ajax({

        type: "POST",
        url: "/Controller/Action",
        data: dataString,
        cache: false,
        dataType: "json",

        success: function (data) {

            alert('success!');
        },

        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(XMLHttpRequest + "<br />" + textStatus + "<br />" + errorThrown);

        }

    }); 

}

In my controller file I have:

    public ActionResult Action()
    {
        return View();
    }



    [HttpPost]
    public ActionResult Action(string testinput, string testinput2)
    {
        return View();
    }

When clicked on “click me” button, I get the following error:
“parsererror
Invalid JSON: “

What am I doing wrong? I am simply trying to pass form data to jquery .ajax.

The alert statement outpust “testinput=gdfgf&testinput2=gfgfd” which is the correct values I entered. SO the error seems to be when serializing….
I am using MVC 3 with razor…I had the impression that passing data between model/view and javascript code was made easier.

  • 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-26T09:34:06+00:00Added an answer on May 26, 2026 at 9:34 am

    I am almost positive that has nothing to do with the data you pass to the $.ajax call and everything with the data returned by /Controller/Action. Open up Fiddler and examine the response. it is likely malformed (or not JSON at all).

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

Sidebar

Related Questions

I have the following html snippet: <a href=page1.aspx class=title>page title goes here</a><br /> <span
I have this html code <html> <head> <title>JQuery Problem 2</title> <script type=text/javascript src=jquery-1.4.min.js></script> <script
I have the following code <html> <head> <title>Test</title> <style type=text/css> <!-- body,td,th { color:
I have html and css as below - .title { display: block; background-color: red;
I have a html main.html as given ----- main.html---------------- <title>FlexTrail</title> <script src=main.js></script> <frameset rows='200,200'>
I have the HTML given below: <ul id=thumbsPhotos> <li src=/images/1alvaston-hall-relaxing-lg.jpg onclick=updatePhoto (this.title)><img src=/images/1alvaston-hall-relaxing-sl.jpg width=56
I have some html snippet <div id=title>This is title<span id=close>X<span><div> The width of this
Ok, so as the title says, I have an HTML page that I fetch
I have the following HTML <html xmlns=http://www.w3.org/1999/xhtml > <head runat=server> <title></title> <style> .box {
I have the following html code: <h3 id=headerid><span onclick=expandCollapse('headerid')>&uArr;</span>Header title</h3> I would like 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.