获得从AJAX调用JSON对象 [英] Get JSON object from AJAX call

查看:104
本文介绍了获得从AJAX调用JSON对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的 AJAX 的JavaScript 。在我的项目,我一定要得到一个 JSON 对象我的的JavaScript 文件。我使用喷雾JSON ,它显示我在URL中JSON对象。 的http://本地主机:8081 /所有的模块

I'm new to AJAX and javascript. In my project, I have to get a json object in my javascript file. I've used spray-json and it shows me the json object in the url. http://localhost:8081/all-modules

{
  "status": "S1000",
  "description": "Success",
  "results": ["module1", "module2", "module3"]
}

我的Ajax调用

My Ajax call

  $.ajax({
        url: 'http://localhost:8081/all-modules',
        dataType: 'application/json',
        complete: function(data){
            alert(data)
        },
        success: function(data){
            alert(data)
        }

它返回一个警告 [对象的对象] 。什么是这里的问题?

It returns an alert [object Object]. What is the issue in here?

推荐答案

如果您希望看到的JSON对象中的所有数据,使用 JSON.stringify 此处是指 的更多细节。

If you wish to see all the data in the JSON object, use JSON.stringify Refer here for more details

希望有所帮助。

这篇关于获得从AJAX调用JSON对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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