相关疑难解决方法(0)

通过JSON将对象数组发布到ASP.Net MVC3

我正在寻找通过JSON将对象数组发布到MVC3的解决方案.

我正在处理的示例代码:http: //weblogs.asp.net/scottgu/archive/2010/07/27/introducing-asp-net-mvc-3-preview-1.aspx

JS:

var data = { ItemList: [ {Str: 'hi', Enabled: true} ], X: 1, Y: 2 };

$.ajax({
    url: '/list/save',
    data: JSON.stringify(data),
    success: success,
    error: error,
    type: 'POST',
    contentType: 'application/json, charset=utf-8',
    dataType: 'json'
});
Run Code Online (Sandbox Code Playgroud)

ListViewModel.cs:

public class ListViewModel
{
    public List<ItemViewModel> ItemList { get; set; }
    public float X { get; set; }
    public float Y { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

ItemViewModel.cs:

public class ItemViewModel
{
    public string Str;   // originally posted with: { get; …
Run Code Online (Sandbox Code Playgroud)

arrays post json asp.net-mvc-3

65
推荐指数
3
解决办法
7万
查看次数

通过GET方法发送值

我一直在尝试通过GET方法将数据发送到服务器,但我无法找到办法.我在异步任务中尝试了很少的代码,但没有.web服务是在cakePhp中制作的,格式如下:

Base_URI/users/add.json?json={“email”: xxx@x.com, “password”: “xxxxxxxxx”, “first_name”: “Xyz”, “last_name”: “Xyz”}
Run Code Online (Sandbox Code Playgroud)

要求Android专家找到摆脱这个问题的方法.谢谢

这是代码:

List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
            nameValuePairs.add(new BasicNameValuePair("email", UserDummy.email));
            nameValuePairs.add(new BasicNameValuePair("password", UserDummy.password));
            nameValuePairs.add(new BasicNameValuePair("first_name", UserDummy.fname));
            nameValuePairs.add(new BasicNameValuePair("last_name", UserDummy.lname));
            // Making HTTP request
    try {

        // check for request method
        if (method == "POST") {
            // request method is POST
            // defaultHttpClient
            DefaultHttpClient httpClient = new DefaultHttpClient();
            HttpPost httpPost = new HttpPost(url);
            httpPost.setEntity(new UrlEncodedFormEntity(params));

            HttpResponse httpResponse = httpClient.execute(httpPost);
            HttpEntity httpEntity = httpResponse.getEntity();
            is = httpEntity.getContent();

        } else if (method == "GET") …
Run Code Online (Sandbox Code Playgroud)

android

6
推荐指数
1
解决办法
6481
查看次数

使用JSON和MVC将PDF返回给浏览器?

我有如下链接.

@Html.ActionLink("Create Report", "Screenreport", "Reports", null, new { @class = "subNavA AddBorderTop", id = "screenReport", title = "Create Report" })
Run Code Online (Sandbox Code Playgroud)

单击链接后,我有一个以下jQuery代码,它创建一个JSON对象并发布信息.

$().ready(function () {

   // Create Report fron the screen data
   $("#screenReport").live("click", function (event) { GenerateScreenReport(this, event); });

}) /* end document.ready() */

function GenerateScreenReport(clikedtag, event) {

   var table = $(".EvrakTable").html();
   var screendata = tableParser(table);
   var Screentable = { Screenlist: screendata };

   var myurl = $(clikedtag).attr("href");
   var title = $(clikedtag).attr("title");


   $.ajax({ 
      url: myurl,
      type: 'POST',
      data: JSON.stringify(Screentable),
      dataType: 'json',
      contentType: …
Run Code Online (Sandbox Code Playgroud)

pdf asp.net-mvc json

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

json ×2

android ×1

arrays ×1

asp.net-mvc ×1

asp.net-mvc-3 ×1

pdf ×1

post ×1