English 中文(简体)
JSON用 Java本进行扼杀性评价,将其价值与 Java本
原标题:JSON string evaluation with JavaScript, and getting it s value with JavaScript

我有这种情况(我的服务器还击了一名JSON):

{"success": true, "users": [1, 3, 4, 8]}

然而,在利用这种请求时,我收到了这种答复,作为“指示”:

var availableUsers = $.ajax({
    url: absPath +  /users/findUsers ,
    type:  POST ,
    data: {contents: $( #messageTo ).val()},
    dataType:  json ,
    async: false
}).responseText;

带:alert(型号(现存的用户)); I d :string上调回数值。

在这样做时:

window.eval(见httpsers); 它获得了预期的评价,成为 Java语。

我怎样才能得到有效的JSON答复(用假象作假)转换成可上网查阅的 Java本 目的或我如何适当评价从服务器返回的舱位?

感谢!

最佳回答

try setting the content type of your request to application/json read more here: What is the correct JSON content type?

问题回答

为什么不能让JSON的物体退步? www.un.org/Depts/DGACM/index_french.htm

$.ajax({
     url: absPath +  /users/findUsers ,
     type:  POST ,
     data: {contents: $( #messageTo ).val()},
     dataType:  json ,
     success: function(data){
         var availableUsers = data;
         alert(typeof availableUsers);
     },
     async: false 
});

有了这种反馈,你可以做你从服务器上来的物体所想要的东西。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签