0

不工作

$.post('Schoolyear/Create', { data: JSON.stringify({ schoolyearId: 1 }) });

抛出异常内部服务器错误 500:无效的 json 原语“数据”

作品

$.ajax('Schoolyear/Create', { data: JSON.stringify({ schoolyearId: 1 }), type: 'POST' });

为什么我不能使用显式 $.post 而必须编写类型?

4

1 回答 1

0

Try it like this:

$.post( "Schoolyear/Create", { "schoolyearId": 1 } );

You don't need the JSON.stringify as its already a json string. And you don't need the data part either. See jquery $.post page for more examples.

于 2013-10-01T20:26:50.207 回答