weixin_33724059 2012-11-21 15:08 采纳率: 0%
浏览 32

使用iecors插件的Ajax Post

To get around cross Domain issues in ie8 + 9 I started to write my own XDomainRequest wrapper. Until joy, I discovered the iecors jQuery plugin on github https://github.com/dkastner/jquery.iecors. It works by modifying jQuery's AJAX transaction. I didn't have to modify my plethora of getJSON AJAX calls, which was a welcome sigh of relief.

However, when I use the $.post method response data is returned as a string. This causes problems because throughout the application the functions are setup to process json objects.

I have done a lot of reading around this and I know there are a ton of common pitfalls. But everything seems to work except for post responses. Can I perhaps preprocess post response data to make it an object?

  • 写回答

1条回答 默认 最新

  • George_Fal 2012-11-21 15:14
    关注

    jQuery will usually alter the returned data type based on the response headers. Your script that returns the (hopefully valid) JSON string should emit the Content-Type: application/json header first. Of course, if everything returned is JSON, you could always use

    $.ajaxSetup({'dataType': 'json'})
    
    评论

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作