json

Ajax returned text read differently by Firefox and IE

I am returning a json object that Firefox reads correctly but IE doesnt. for example: if( data.returnedText=="OptionA"){... this is true as it should be in Firefox, but IE doesnt match. ...

How can I use django with JSONP to load content from my other website?

I have two sites written with Django. What I want is to load a content from one site into another. I found out that best choice to do this would be using .getJSON and JSON-P but I have no idea how to put this things (Django, jQuery and JSONP) together. Any help from more expirienced users? EDIT I'm trying to achive an ongoing process ...

A good way to send complex objects with ajax?

In my web app, I have some complex objects written with JavaScript (ie nested arrays, objects within objects withing objects, etc) and the nature of my app relies on these. I need to send all the data to PHP so that I can save it to the database. What is an efficient, easy way to send my objects to PHP? I tried JSON, but got strange erro...

jQuery $.getJSON works only once for each control. Doesn't reach the server again.

First my code $.getJSON("./posts/vote/" + postId + "/1", null, function(result) { if (result.result == true) $("#pst" + postId + " > .pstside > .rank > .score").html(result.voteCount); }); I have a bunch of buttons each with code which brings some voting results from an ASP.Net MVC controller action. This works well the fir...

What kind of notation is this?

I've a string which looks like this: [{text:"key 1",value:"value 1"},{text:"key 2",value:"value 2"},{text:"key 3",value:"value 3"}] I'm not sure what kind of notation this is, AFAIK this is generated by a ASP .NET backend. It looks a lot similar to JSON but calling json_decode() on this fails. Can someone bring me some light on this ...

get json array back through javascript in jquery

Hey I have an external file in php, outputed as json format I want the data to be send back to jquery in arrays .... how to do it ? php: $options = "<option value="data0">data 0<option> <option value="data1">data 1<option> <option value="data2">data 2<option> <option value="data3">data 3<option> <option value="data4">data 4<option...

Restlet implementing post with json receive and response

First, what i wanted to know is what i am doing is the right way to do it. I have a scenario where i have will receive a json request and i have to update the database with that, once the db is updated i have to respond back with the json acknowledgment. What i have done so far is create the class extending application as follows: ...

How can I show a hidden DIV if a AJAX JSON response shows the proper data?

I am working on a AJAX/jquery notification script. Currently it retunrs a whole fhtml formatted page every 10 seconds in the AJAX response. The page it is returning is a PHP page which only shows items that should be shown (only items that have something NEW show up, like a new mail message or a new comment etc..) I am wanting to cha...

Asp.net MVC json or Json.net?

Hi I am now using asp.net mvc and wondering what is a better choice using the built in Json or Json.Net I am not sure if one has an advantage over another. Also if I do choose to go down the route of Json.Net then should I go with the stable version or beta 4? I am not sure how unstable the betas are. ...

Call Json by index?

Hi I want to return some errors to my jquery method. What is happening is I am doing a post(with a type of "json") and if they get errors I want to display the error back to them. I am doing client side validation but some of these are errors that are like server related(ie the database died or something and that update could not happen...

JSON.parse Html content

I am trying to call JSON.parse, where one of the values is html. I have tried running HtmlEncode, to no avail. FF seems to work fine, however IE7 throws an error. Here is an example of my json string that I wish to parse. [{"Title":"Bed","ImageUrl":"~\\/Test\\/sample-product.ashx?w=410","ProductUrl":"\\/products\\/AB10005.aspx","Descr...

Scan through JSON technique

I have this JSON for smilies list var smiliesList = { "sm-1":":)", "sm-2":":(", "sm-3":";)" } There are lots more than 3 actually. In other part of the code I use smiliesList["sm-1"] to get ":)". However, I want to get the opposite now. I have a text string, I want to go through the whole smiliesList and replace ":)" with "sm-1" and...

Serializing object to JSON and getting format of ...

What C-sharp type can I serialize to get JSON object with format "name":[[1,2,3],[1,2,3],[1,2,3]] If serialize array like this public int[,] data = {{23,21,10},{45,43,50},{23,21,90}}; it gives format of "data":[23,21,10,45,43,50,23,21,90] Or more generally, is there some list where i can find what type is serialized in which format? ...

.NET/MVC JSON response opens up dialog box to save

I am trying to submit a form via jquery's ajax method in my .net mvc application. I've set the dataType to json and the contentType to "application/json; charset=utf-8". In my controller action, I'm returning a JsonResult. For some reason, the JSON response doesn't get handled correctly and instead I get a dialog box to save a file ...

Why isn't DataContractJsonSerializer serializing my Id property?

I'm using LINQ-to-SQL for CRUD functionality, and DataContractJsonSerializer to serialize the object to JSON. I am also using ASP.NET MVC's data binding to post values to an MVC action that does the inserting. The problem is that it will serialize all of the properties except the Id property. I've got the model set up as so: [Serializab...

Sorting a JSON object in Javascript

I've been looking for a while and want a way to sort a JSON object like this: { method: 'artist.getInfo', artist: 'Green Day', format: 'json', api_key: 'fa3af76b9396d0091c9c41ebe3c63716' } and sort is alphabetically by name to get: { api_key: 'fa3af76b9396d0091c9c41ebe3c63716', artist: 'Green Day', format:...

PHP json_decode notation issue

I am having an issue dealing with the notation used in a JSON file I am trying parse. Some of the nodes have . (periods) in the names which escapes object-notation ($json = $article->rssFeed.url;) How would I go about selecting the nodes. Do I need to str_replace the .(periods), or is there some other notation I can use? Here is a sni...

Javascript array indexed by strings can't be converted to JSON using JSON.stringify?

I've been trying to stringify a javascript array which is keyed by strings. JSON always stringifies the array as empty ([]). var arr = new Array(3); arr['A'] = "Foo"; arr['B'] = "Bar"; arr['C'] = "Baz"; var str = JSON.stringify(arr); If I replace the 'A', 'B', 'C' with 0,1,2 then the array is stringified correctly. I'm sure I'm missi...

JSON is not defined, Chrome

I have some JS that runs fine in FF and IE but in Chrome I see the following error: uncaught exception ReferenceError: JSON is not defined I presume I need to include something but I'm not sure what. Help? Also, any clue why this might work on IE/FF but not Chrome? Btw, I'm using JSON.stringify() in my script. ...

ASP.NET MVC JsonResult and JQuery flot

I'm trying to use the jquery flot graphing plugin with asp.net mvc. I'm trying to dynamically pull data from a JsonResult in order to populate the graph. My problem is that I can't seem to get the data returned from the JsonResult in the correct format. Here is my server side code: public ActionResult JsonValues() { I...