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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:25:30+00:00 2026-06-02T02:25:30+00:00

So Im having an issue with my Json Call to the Controller. Im getting

  • 0

So Im having an issue with my Json Call to the Controller. Im getting an error
“parseerror – Unexpected token <“

my code is as follows in my view:

$("select[name='SelectedProjectStatus']").change(function () {

        var DashboardModel = {
            SelectedProjectStatus: $("select[name='SelectedProjectStatus']").val(),
            Page: 1
        };

        $.ajax({
            url: '@Url.Action("Dashboard", "Dashboard")',
            type: 'POST',
            data: JSON.stringify(DashboardModel),
            dataType: 'json',
            contentType: 'application/json; charset=utf-8',
            success: function (data) {
                $('#DashboardResult').replaceWith(data);
            },
            error: function (request, status, err) {
                alert(status);
                alert(err);
            }
        });

    });

and in my controller:

    [HttpPost]
    public ActionResult Dashboard(DashboardModel dashboard)
    {
        var MyProjects = EFProject.Project.Where(x => x.UserID == 1);
        if (dashboard.SelectedProjectStatus != 0)
            MyProjects = MyProjects
                        .Where(x => x.Status == dashboard.SelectedProjectStatus)
                        .OrderByDescending(p => p.AuditingCD)
                        .Skip((dashboard.Page - 1) * PageSize)
                        .Take(PageSize);
        else
            MyProjects = MyProjects
                      .OrderByDescending(p => p.AuditingCD)
                      .Skip((dashboard.Page - 1) * PageSize)
                      .Take(PageSize);

        DashboardModel model = new DashboardModel
        {
            Projects = MyProjects,
            PagingInfo = new PagingInfo
               {
                   CurrentPage = dashboard.Page,
                   ItemsPerPage = PageSize,
                   TotalItems = EFProject.Project.Where(x => x.UserID == 1).Count()
               }
        };
        if (Request.IsAjaxRequest())
        {
            return PartialView("DashboardResult", model);
        }
        else
        {
            return View(model);
        }
    }

The partial view im trying to render only has the following:

@using BidThatProject.Web.Models.NonReusableModels.ProjectManagment
@model DashboardModel
<div id="DashboardResult">

</div>

and the parent view obviously has the div with the same id’s. It should work at least by showing in me an empty space, but it seems that its having a problem parsing the data back to the view. It could be that its not reading it as a application/json type? I really have no idea.

  • 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-02T02:25:33+00:00Added an answer on June 2, 2026 at 2:25 am

    use Json Result and return Json(model);

    public JsonResults MyTest(){
        var model = FROM b in Table WHERE b.id == 1 select b;
        return Json(model);
    }
    
    $.ajax({
            url: '@Url.Action("Dashboard", "Dashboard")',
            type: 'POST',
            data: {page: 1, selected: $("select[name='SelectedProjectStatus']").val() },
            dataType: 'json',
            contentType: 'application/json; charset=utf-8',
            success: function (data) { // 
                // process the json object into html page
            },
            error: function (request, status, err) {
                alert(status);
                alert(err);
            }
        });
    

    here is an edit, as the blog post is getting a partial view via ajax, not json data via ajax:

    public ActionResults MyTest(SearchModel  results){
        var model = FROM b in Table WHERE b.id == 1 select b;
        return PartialView("ViewName",model);
    }
    // you create a partial view that takes in your model
    $.ajax({
        url: '/ajax/MySearch',
        type: 'POST',
        data: $("form").serialize(),        
        success: function (data) { // 
            $("#searchresults").html(data);
        },
        error: function (request, status, err) {
            alert(status);
            alert(err);
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having an issue getting this jQuery.ajax call to work. When the script executes
I'm having an issue with inserting JSON into a database, my intention is to
I'm having an issue with passing the generated JSON notation of my object to
I am having an issue dealing with the notation used in a JSON file
i am having issue with loading my selector via a jquery ajax load call
I am having issues with storing JSON data to sqlite. This is the code
I am having an issue with the using jqGrid with JSON data returned from
I'm having an issue obtaining json from a piece of hardware on a local
I am having an issue retrieving the key from this JSON result returned from
I am having an issue trying to post a JSON string using dojo.xhrPost 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.