Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/459.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将数组从js文件传递到控制器中的方法并获取值_Javascript_C#_Ajax_String_Model View Controller - Fatal编程技术网

Javascript 将数组从js文件传递到控制器中的方法并获取值

Javascript 将数组从js文件传递到控制器中的方法并获取值,javascript,c#,ajax,string,model-view-controller,Javascript,C#,Ajax,String,Model View Controller,我试图将值从js传递到Home controller中的方法网关,我希望返回结果(整数) 您正在POST请求中传递url查询参数,根据设计,该请求应该是一个有效负载主体。为什么不在数据对象中添加另一个名为dates的属性,并将其值设置为dates数组 $.ajax({ url: '/Home/gateway', type: 'POST', dataType: 'json', data: { id: 'value', dates }, success: ()

我试图将值从js传递到Home controller中的方法网关,我希望返回结果(整数)


您正在POST请求中传递url查询参数,根据设计,该请求应该是一个有效负载主体。为什么不在数据对象中添加另一个名为dates的属性,并将其值设置为
dates
数组

$.ajax({
  url: '/Home/gateway',
  type: 'POST',
  dataType: 'json',
  data: {
    id: 'value',
    dates
  },
  success: () => {
    alert("success");
  },
  error: () => {
    alert('error');
  }
});

请让我们至少知道,什么是从后端或左右的结构响应。
$.ajax({
  url: '/Home/gateway',
  type: 'POST',
  dataType: 'json',
  data: {
    id: 'value',
    dates
  },
  success: () => {
    alert("success");
  },
  error: () => {
    alert('error');
  }
});