Ajax从C#返回日期到ajax结果

时间:2016-06-10 10:33:28

标签: javascript c# asp.net ajax linq

您好我的代码在Linq中有一个列Date。

当我使用ajax在函数后面调用此代码时,它将日期列返回为“/ Date(1464710400000)/”

我该如何处理?

这是我的代码:

function SetSubsVal() {
        $.ajax({
            type: "POST",
            url: "AccountManagement.aspx/GetModeofPayment",
            data: '{ptype: true, regid:' + $("#hdnRegID").val() + '}',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (result) {
                if (result.d.length != 0) {
                    $(result.d).each(function (i, data) {
                        try { $('#subsType').val(data.SubscriptionType.toString()); } catch (err) { }
                        try { $('#subscriptionfee').val(data.Fee.toString()); } catch (err) { }
                        try { $('#invRcptSub').val(data.InvoiceRecipient.toString()); } catch (err) { }
                        try {
                            debugger;
                            $('#invDateSub').val(data.InvoiceDate);
                        } catch (err) { }
                        try { $('#startDateSub').val(data.StartDate.toString()); } catch (err) { }
                        try { $('#endDateSub').val(data.EndDate.toString()); } catch (err) { }
                        try { $('#numberoforder').val(data.NumberOfOrder.toString()); } catch (err) { }
                        try { $('#ordersleft').val(data.OrderLeft.toString()); } catch (err) { }
                        try {
                            if (data.Active) {
                                prevSettup[0].SubsActive = '1';
                                $('#lblActive').trigger('click');

                            }
                        } catch (err) { }
                    })
                }
            }
            ,
            error: function (err) {

                alert(err.responseText);
            }
        });
    }

这里是我的代码:

[WebMethod]
    [System.Web.Script.Services.ScriptMethod(ResponseFormat = System.Web.Script.Services.ResponseFormat.Json)]
    public static List<AccountPaymentMode> GetModeofPayment(bool ptype, int regid)
    {
        List<AccountPaymentMode> payments = new List<AccountPaymentMode>();

        using (EDMEntities entity = new EDMEntities())
        {

            payments = entity.AccountPaymentModes.Where(w => w.RegID == regid && w.IsSubscription == ptype).ToList();
        }


        return payments;
    }

0 个答案:

没有答案