1

I am developing an web api application in MVC4 using latest version of Entity Frameworks.

I am using AJAX from my View to call my GET function for a user in one of my API classes, which looks like this:

        $.ajax({
            url: '../api/UserAPI/Get',
            cache: false,
            type: 'GET',

            contentType: 'application/json; charset=utf-8',statusCode: {
                200: function (data) {
                    $('#email').val(data.Email);
                    $('#firstname').val(data.FirstName);
                    $('#lastname').val(data.LastName);
                    $('#birthdate').val(data.BirthDate);
                }
            }
        });

In the success function(200) i want to write some values of a user in some textfields. This is where I get the problem. The data.BirthDate I receive in my View is in a very strange format.

In my API class, were the connection between my database and my view are, the DateTime is like this: 1/1/1993 12:00:00 AM

But as I want to write out the date im receiving in a textfield, like this:

$('#birthdate').val(data.BirthDate);

the output is in this format: /Date(725842800000+0100)/

The output I want is like this: 19930101

Anybody having a clue why the strange format change and in that case how to avoid it/convert it in a good way?

Hope I explained it well enough for people to understand my problem!!

Best regards!

  • 1
    Check out [this link](http://stackoverflow.com/questions/82058/deserializing-client-side-ajax-json-dates). Basically, JavaScript has no idea how to de-serialize the .NET serialization of a date, so you need to do that as an extra step. – Mark M May 16 '12 at 13:50
  • Thank you Mark, will deff check that out!! – Mathias Fernström May 16 '12 at 13:55

0 Answers0