jQuery Datatables中不存在必需的JSON参数 [英] Required JSON parameter is not present in jQuery Datatables

查看:190
本文介绍了jQuery Datatables中不存在必需的JSON参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从jQuery Datatables提交我的数组,用于服务器端处理,格式如下:

创建数组

  var testArr = []; 
testArr.push('A')

$('#form')。提交函数

  $。ajax({
url:'run',
data:testArr,
dataType:json,
success:function(testArr){
alert(Data Saved:+ testArr);
}
});`

在Spring Controller端,我的注释看起来像这样

  @RequestMapping(value =/ run,method = RequestMethod.POST,
headers = Accept = application / json)
public String run(@RequestParam(testArr)JSON testArr){

当我提交服务器端处理数据时,它会抛出一个错误,指出


必需的JSON参数'testArr '不存在


我无法理解我做错了什么。请帮助。

解决方案

jSon和jSonP是对。你没有发送一对为了测试目的,请尝试testArr.push({'A':'a'})


ps:我是新手!


I am submitting my array from jQuery Datatables for server side processing, in the following form

Creating the array

var testArr = [];  
testArr.push('A')

and under the $('#form').submit function

$.ajax({
    url: 'run',  
    data: testArr,  
    dataType :"json",  
    success: function(testArr){  
        alert( "Data Saved: " + testArr); 
    }  
});`

And on the Spring Controller side , my annotation looks like this

@RequestMapping(value="/run", method=RequestMethod.POST,
                headers="Accept=application/json")  
public String run(@RequestParam("testArr") JSON testArr) {

When I submit the data for server side processing , it throws me an error stating that

Required JSON parameter 'testArr' is not present

I am unable to understand what am I doing wrong. Please help.

解决方案

jSon and jSonP are pairs. You are not sending a pair. For test purposes, try testArr.push("{'A':'a'}")

ps: I am a novice!

这篇关于jQuery Datatables中不存在必需的JSON参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆