Jquery Ajax调用 - 读取数据

时间:2016-07-27 18:41:34

标签: jquery ajax

我试图阅读\ map我的对象,但无法看到我怎么出错?

plt.figure()
x = []
for item in circ_list:
    x.append(float(item))
mean = np.mean(x)
std = np.std(x)
target_upper_bound = mean + 3 * std
target_lower_bound = mean - 3 * std

total_intermid = wear_limit[1] - wear_limit[0]
ten_percent_intermid = total_intermid / 10.0
plt.gca().axes.get_yaxis().set_visible(False)
plt.xlim([wear_limit[0],  wear_limit[1]])

plt.plot(x, np.zeros_like(x), 'x')
plt.plot(np.array([mean, mean + 2 * std, mean - 2 * std]),
         np.zeros_like(np.array([mean, mean + 2 * std, mean - 2 * std])), '|')

for i in x:
    plt.annotate(str(i), xy=(i, 0))
plt.annotate('mean', xy=(mean, 0))
plt.annotate('mean+3*std', xy=(target_upper_bound, 0))
plt.annotate('mean-3*std', xy=(target_lower_bound, 0))
plt.show()

控制器

var model = { LastName: templastname, FirstName: tempfirstname, Mobile: tempmobile, AccountId: tempaccountId, Pin: tempPin }
$.ajax({
            url: "/Client/Get/",
            type: 'GET',
            data: $.param(model, true),
            cache: false,
            crossDomain: true,
            async: true,
            dataType: 'json',
            success: function (data) {

            },
            error: function (event) {

            },
            headers: {
                'Access-Control-Allow-Origin': '*'
            },
        });

型号值:

 public JsonResult GetClient(string model)
        {
            var e = new ClientMapper();
            var objJavascript = new JavaScriptSerializer();

            e = objJavascript.Deserialize<ClientMapper>(model); <--Blows up
}

 private class ClientMapper
        {
            public string FirstName { get; set; }
            public string LastName { get; set; }
            public string AccountId { get; set; }
            public string Mobile { get; set; }
            public string Pin { get; set; }
        }

我是如何正确格式化的?

1 个答案:

答案 0 :(得分:0)

而不是在函数参数中写string model而不是写“ ClientMappe r”使该类公开。 C#Mvc将auson将json映射到对象

public class ClientMapper {....}
public JsonResult GetClient(ClentMapper model)