json

How does Facebook chat avoid continuous polling of the server?

I am trying to understand how Facebook's chat feature receives messages without continuously poling the server. Firebug shows me a single GET XmlHttpRequest continuously sitting there, waiting for a response from the server. After 5 minutes, this never timed out. How are they preventing timeout? An AJAX request can just sit there like...

Ruby data structure to render a certain JSON format

[ { "id":"123", "name":"House" }, { "id":"1456", "name":"Desperate Housewives" }, { "id":"789", "name":"Dollhouse" }, { "id":"10", "name":"Full House" } ] How can I render to produce this JSON format from within Ruby? I have all the data from the DB (@result) and d...

PHP array : simple question about multidimensional array

Hello, i've got a SQL query which returns multiple rows, and i have : $data = array( "nom" => $row['nom'] , "prix" => $row['rapport'], "average" => "$moyenne_ge" ); which is perfect, but only if my query returns one row. i tried that : $data = array(); $data[$row['nom']]["nom"] = $row['nom'] ; ... $data[$row['nom'...

Problem with accessing in DOM with jQuery

Hello, I changed the tree of my JSON-P output, and i cannot access to my object DOM anymore : Here's my output : jsonp1271634374310( {"Inter-Medias": {"name":"Inter-Medias","idGSP":"14","average":"80","services":"8.86"} }); And here's my jQuery script : success: function(data, textStatus, XMLHttpRequest){ widget = data.name; w...

serializing JSON files with newlines in Python

I am using json and jsonpickle sometimes to serialize objects to files, using the following function: def json_serialize(obj, filename, use_jsonpickle=True): f = open(filename, 'w') if use_jsonpickle: import jsonpickle json_obj = jsonpickle.encode(obj) f.write(json_obj) else: simplejson.dump(obj, f) f.cl...

How to reslove mysql_fetch_assoc(): problems!

When i use the code below, im getting this error: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource when returning the data, anyone can fix it? Thanks! <?php $mysql_server_name="localhost"; $mysql_username=""; $mysql_password=""; $mysql_database=""; $conn=mysql_connect($mysql_server_name, $mysql_...

Copying cookies cross-domain, why is IE blocking cookies other browsers are sending with the SCRIPT tag

Trying to copy a cookie from second.com to first.com, with full control of both domains. Previously an iFrame was used, however this is not able to work across all browsers as it touched on 'third-party cookies' which are hard to implement and impossible in Safari and Chrome. The new approach uses a SCRIPT tag pointing to second.com an...

Silverlight, Grids, MVC, HTTP Post

I'm trying to create an editable grid using Asp.Net MVC 2 and Silverlight (specifically a grid that displays info from a db and allows users to update that info). So far I've managed to put a silverlight grid on an a view, using this technique However I have no way of getting the updated data from the silver light grid. Is there anyway...

jQuery autopopulate select drop down from JSON issues

I have an issue regarding to auto populating a select dropdown from jQuery/JSON data which is return from a ColdFusion CFC, the code is below: $(function(){ $("#licences-add").dialog({autoOpen:false,modal:true,title:'Add Licences',height:250,width:380}); }); function openAddLicence(intInstanceID,szName,szDatasourceName){ $.getJSON('/...

Jquery datepicker that consumes json data which are future dates...

Is there any jquery datepicker that consumes json data... My json data would be a list of future dates that belongs to any month should be consumed by my datepicker which should be disabled and highlighted with a color.... ...

Is using advanced constructs (function, new, function calls) in JSON safe?

JSON is a nice way to pass complex data from my server side code to client side JavaScript. For example, in PHP I can write: <script type="text/javascript> var MyComplexVariable = <?= BigFancyObjectGraph.GetJSON() ?>; DoMagic(MyComplexVariable); </script> This is pretty cool, but sometimes you want to pass more than basic date...

Unable to create json using gson

I have to make dynamic hashes, so the class example won't work since the class variables are static. I am sending in a hashmap object to toJson but it isn't working. Any suggestions on what to do? ...

How should i output my MySQL data into json in this kind format?

Im not sure how to output MySQL data into formats below. (eg: timelist, usersex, userage from table users.) <script type="text/javascript"> timeList = new Array(), userSex = new Array('female','male','male'), userAge = new Array('21','36'), userMid = new Array('liuple','anhu'); </script> Thanks! ...

Error converting JSON to .Net object in asp.net

Hello Guys, I am unable to convert JSON string to .net object in asp.net. I am sending JSON string from client to server using hidden field (by keeping the JSON object.Tostring() in hidden field and reading the hidden field value in code behind file) Json string/ Object: [[{"OfferId":"1","OrderValue":"11","HostingTypeID":"3"}, {"Offe...

POST serialized JSON object to a Coldfusion remote method instead of using FORM

I have javascript object which consists of complex array of structures with nested structures of other javascript objects created dynamicaly on page etc. long story. I can't use form since my vars would be like 2_34_x_y_foo_bar_235423 due to the nature of UI. When I send that stringified object using GET .ajax request to a remote cfc me...

Cannot output json from MySQL - getting null value

I'm using following code but cannot return data from MySQL. This is the output: <script type="text/javascript"> var somethings= [null,null,null]; </script> It does have three post, but I couldn't get the title(message) output. EDIT: this is the code I'm using: <?php $session = mysql_connect('localhost','name','pass'); ...

Getting Null value with JSON from MySQL, how to retrive data from MySQL to JSON correctly?

I'm using following code but cannot return data from MySQL. This is the output: <script type="text/javascript"> var somethings= [null,null,null]; </script> It does have three post, but I couldn't get the title(message) output. EDIT: this is the code I'm using: <?php $session = mysql_connect('localhost','name','pass'); ...

how to extract information from JSON using jQuery

Hi, I have a JSON response that is formatted from my C# WebMethod using the JavascriptSerializer Class. I currently get the following JSON back from my query: {"d":"[{\"Lat\":\"51.85036\",\"Long\":\"-8.48901\"},{\"Lat\":\"51.89857\",\"Long\":\"-8.47229\"}]"} I'm having an issue with my code below that I'm hoping someone might be able...

PHP: Join two separate mysql queries into the same json data object

I'm trying to mesh the below mysql query results into a single json object, but not quite sure how to do it properly. $id = $_POST['id']; $sql = "SELECT contracts.po_number, contracts.start_date, contracts.end_date, contracts.description, contracts.taa_required, contracts.account_overdue, jobs.id AS jobs_id, jobs.job_number, companies....

Why does Google append while(1); in front of their JSON responses?

This is something I've always been curious about, is exactly why Google appends while(1); in front of their (private) JSON responses. For example, here's a response while turning a calendar on and off in Google Calendar: while(1);[['u',[['smsSentFlag','false'],['hideInvitations','false'],['remindOnRespondedEventsOnly','true'],['hideInv...