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

  • Home
  • SEARCH
  • 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 7912183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:32:03+00:00 2026-06-03T13:32:03+00:00

I have a MVC application that produces the following output in a browser when

  • 0

I have a MVC application that produces the following output in a browser when I visit a certain URL:

[{"name":"Victoria Day","date":"\/Date(1337583600000)\/"},{"name":"Canada Day","date":"\/Date(1341212400000)\/"},{"name":"Civic Holiday","date":"\/Date(1344236400000)\/"},{"name":"Labour Day","date":"\/Date(1346655600000)\/"},{"name":"Thanksgiving","date":"\/Date(1349679600000)\/"},{"name":"Remembrence Day","date":"\/Date(1352707200000)\/"},{"name":"Christmas","date":"\/Date(1356422400000)\/"},{"name":"Boxing Day","date":"\/Date(1356508800000)\/"}]

Of course, the source code has a bunch of html tags wrapped around that.

How can I assign this raw information to a Javascript array?

  • 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-03T13:32:06+00:00Added an answer on June 3, 2026 at 1:32 pm

    Considering your http request returns the raw data that you’ve posted, you should be able to use:

    var text = $.trim($(document.body).text());
    var cleanedText = text.replace(/\\\/Date\(/g,"").replace(/\)\\\//g,"");
    var holidays = $.parseJSON(cleanedText); // This is your array!
    
    alert("Loaded " + holidays.length + " holidays. Fifth one is " + holidays[4].name + " celebrated on " + new Date(parseInt(holidays[4].date)).toString());
    
    // Output(the dates should be printed with your preferred timezone offset): 
    // Loaded 8 holidays. Fifth one is Thanksgiving celebrated on Mon Oct 08 2012 10:00:00 
    // GMT+0300 (GTB Daylight Time)
    

    If that output that you want to parse resides in other place, you should load it via jQuery in var text using your custom selector. Note that var cleanedText removes the bad characters from date values, in order to parse them as valid javascript Date objects.

    Leave a comment if you have further questions. Good Luck!

    ​JSFiddle working example: click here

    Edit: You need jQuery.

    Edit2: I think you need to use $.get in order to retrieve your data from a custom url(make sure it’s from the same server or you might run into browser security issues). You should play a little with this and try check if your request goes to the correct path on the server(for example you can check on Google Chome browser under Developer Tools on Network tab all requests data). You should change the content of function(data) { to match your needs.

    var url = 'page.html'; // You should change this with the url that returns your data.
    $.get(url, function(data) {
      alert('The response is: ' + data); // Make sure it's ok
      var text = $.trim(data);
      var cleanedText = text.replace(/\\\/Date\(/g,"").replace(/\)\\\//g,"");
      var holidays = $.parseJSON(cleanedText); // This is your array!
    
      alert("Loaded " + holidays.length + " holidays. Fifth one is " + holidays[4].name + "           celebrated on " + new Date(parseInt(holidays[4].date)).toString());
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an MVC 2 application that has the following on it; <% using(
I have an ASP.NET MVC application that produces a PDF file when calling an
I have an application, built using MVC, that produces a view which delivers summary
I have an mvc application that I allow businesses to log in using https://storea.mydomain.com
I have an MVC application that is using MEF for the controllers, all working
I have an MVC application that needs to login and verify a user against
I have an mvc application that has been coded to use Windows authentication and
I have an MVC application view that is generating quite a large HTML table
I have a spring mvc application that I have broken up into separate maven
I have an ASP.NET MVC application that uses Fluent NHibernate and AutoMapper. I am

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.