weixin_33698043 2015-01-07 16:06 采纳率: 0%
浏览 910

jQuery $ .post 500错误

I am trying to do $.post call but I keep getting a 500 error and I dont know why,

$http.post('/api/report/action/post', JSON.stringify($scope.user))
            .success(function (data) {
                alert('sucess');
            }).error(function (data, status) {
                alert('error');
            });

the url is correct, is there something wrong with the way I am passing in the data?

  • 写回答

1条回答 默认 最新

  • weixin_33716557 2015-01-07 16:24
    关注

    Error 500 is an error on server side.

    It usually states that the code that is executed by your call to /api/report/action/post has failed.

    It could fail for a lot of thing, of course. Maybe you are passing the wrong parameters, or in the wrong encoding. Or maybe just it has a bug.

    The steps I'd take to debug this would be:

    1) Check what happens when I execute the call directly. Is there an error? Do this error throws more light about the problem?

    2) If there is no error calling the method directly I'd check if my call is correct. Am I passing the correct url? And the correct parameters? Is the data being passed the expected data? It's encoding as the server expects it?

    3) If the direct call works and my remote call seems to be correct I'd try to use a tool like fiddler to check all the steps and data in the call/response data transmission, and try to detect where things get tricky.

    Hope it helps.

    评论

    报告相同问题?

    悬赏问题

    • ¥15 oled显示有问题,初始化后应该啥也不显示,但却亮了一大片
    • ¥15 【通信原理】为什么传信率不变?频带利用率为啥没有二倍
    • ¥15 CANOPEN SDO
    • ¥15 r语言数据集循环获取问题
    • ¥30 求佬们帮助,总是出bug,求佬们解决一下bug
    • ¥15 后端Java转换字符串传给前端,前端如何解析呢?
    • ¥15 psychopy(python为基础的)中引入cmd
    • ¥15 不知道怎么去做关于前端电子请柬
    • ¥15 Ubuntu22.04打开是tty界面。提示OOM
    • ¥15 存储过程或函数中的结果集类型变量如何使用。