weixin_33725126 2018-01-29 15:39 采纳率: 0%
浏览 37

AJAX和Web API出现问题

I've build an WebAPI (.net) application and a simple HTML website for the front-end. Everything worked fine when executing via Visual Studio.

When I tried use this application in my host server, I did sucefully send (POST) a complex object via JSON to the webapi (login) and to "GET" complex objects (User info, configurations, etc...)

But, when I tried to perform a "GET" to obtain a list of object, the server respond: 500 - failed to execute 'send' on 'xmlhttprequest': failed to load '<link to my service>'.

In Resume: GET and POST using objects goes fine GET a list of objects goes bad.

What do I do?

CODE:

function GetService(urlFunc) {

var ret = null;

$.ajax({
    url: urlFunc,
    type: 'GET',
    dataType: 'json',
    async: false,
    crossDomain: true,
    success: function (msg) {
        ret = msg;
    },
    error: function (msg) {
        //LOG EVENTS
        ret = false;
    }
});

return ret;

};

  • 写回答

1条回答 默认 最新

  • 撒拉嘿哟木头 2018-02-07 11:19
    关注

    I found the problem. Actually it was in the webapi. It was not sending (for some reason) the list in Json. When I changed the type of Return (For an array, by example), the AJAX receive the list normally. Now I have to discover how to config the webapi to send the list of objects. Thanks everyone! I will change the code for remove the async too!

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器