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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:09:58+00:00 2026-06-15T17:09:58+00:00

My ajax function: function fetchData(varUrl, varFunc, varData) { if (varData == undefined) varData =

  • 0

My ajax function:

function fetchData(varUrl, varFunc, varData) {
 if (varData == undefined) varData = "";
 var options = {
    type: "POST",
    url: varUrl,
    data: varData,
    contentType: "application/json;charset=utf-8",
    dataType: "json",
    timeout: 8000,
    cache: false,
    beforeSend: ShowLoading(),
    success: varFunc,
    complete: HideLoading(),
    error: function (x, t, m) {
        if (t === "timeout") {
            alert("got timeout");
        } else {
            alert(t+"\r\n\r\n"+m);
        }
    }
  };
  //execute the ajax call and get a response
  var request = $.ajax(options);
}

  function funcA(data){
     $.each(data, function (i, item) {...}
  }

  function funcB(data){
     $.each(data, function (i, item) {...}
  }

C# code:

    public ActionResult AjaxA()
    {
        try
        {
            using (var db = new MvcContext())
            {
                var history = from h in db.Histories.Where(h => h.Id == 2)
                return this.Json(history.ToList());
            }
        }
        catch(Exception)
        {
            return this.Json("");
        }
    }

     public ActionResult AjaxB()
    {
        var history = new List<MyDataType>();
        history.Add( new MyData(...));
          ...
        history.Add( new MyData(...));
        return this.Json(history);
    }

1) If I use fetchData(“AjaxA”, funcA) to get data, it is OK

2) If I use fetchData(“AjaxB”, funcB) to get data, it failed and get error

JSON.parse: unexpected character error

but firebug can get good json data in this case, too.

json data [{“x”:39,”y”:115.5,”Data”:16.743013706957576},{“x”:39.5,”y”:115.5,”Data”:12.353‌​109643128887}]

  • 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-15T17:10:00+00:00Added an answer on June 15, 2026 at 5:10 pm
    Parse error on line 10:
    ...      "Data": 12.353‌​109643128887    }
    -----------------------^
    Expecting '}', ',', ']'
    

    Here you go, I’ve validated the JSON on http://jsonlint.com/

    When I copy the JSON on a text editor, a couple of characters are converted into ?, please check that. It looks like an encoding issue.

    [{"x":39,"y":115.5,"Data":16.743013706957576},{"x":39.5,"y":115.5,"Data":12.353??109643128887}]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My Ajax code $(document).ready(function() { $(#sub).click(function() { $.ajax({ type: POST, url: jqueryphp.php, data: txt1=
I used jQuery's .ajax function like: $.ajax({ type:POST, url:./index.php, data:{ajax_fetch:1,action:fetch_devInfo,nwType:nw_type,devTSN:dev_tsn,devSTime:dev_sTime,devETime:dev_eTime,dev_gType:dev_graphType}, dataType:xml, error:errHandler, success:function(xml,textStatus) {
I have a jQuery AJAX function like this: $.ajax({ url: 'crud/clients.php', dataType: 'json', type:
I am using $.ajax function to send json data to serverside function. var jsonObjects
in the $.ajax function the url part has data.json which is a text file
Suppose I have an AJAX function: function callpage{ $.ajax({ method:get, url:/abc/, data:x=+3 beforeSend:function() {},
I have a jquery-ajax function that sends data to a php script and the
I am trying to do a simple AJAX function to send data from query
I use the jQuery ajax function to send data to 2 php scripts. The
Within a jQuery ajax function data supplied to the callback function on success is

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.