json

Add new data into PHP JSON string

Hello. I have $data as JSON encoded data and I have this string: $new_data = "color:'red'"; that needs to be added to $data so that I can read it from it as a json string. How can I achieve this ? Thank you. ...

PHP json_encode and javascript functions

I need to encode a javascript function into a JSON object in PHP. This: $function = "function(){}"; $message = "Hello"; $json = array( 'message' => $message, 'func' => $function ); echo json_encode($json); outputs: {"message":"Hello","func":"function(){}"} What I want is: {"message":"Hello","func":function(){}} ...

jQuery populate items into a Select using jQuery ajax json, php

I have a select field. I must fill with options taken from a mysql table. Here is some little php code I have done using codeigniter framework $idcateg = trim($this->input->post('idcategory')); $array1 = array( 'result' => $idcateg ); echo json_encode($array1); Now, the jQuery call... $.post("<?=base_url()?>index.php/rubro/list_a...

Is there javascript (prefer jquery) library that automatically maps form elements to JSON?

Background: This is something I have been looking for since before even JSON was known as JSON. Suppose you have the following javascript variable inside your code: jsonroot = { 'fname':'valued' ,'lname':'customer' ,faves:['berry','chocolate','mint'] ,actors:[ {'fname':'brad','lname':'pitt'} ,{'fname':...

How to update Extjs Progress Bar with JSON results?

Hi, I am facing some difficulties in getting my progress bar to retrieve its progress from Json results and update the progress bar based on the timer check of every 10 seconds. I am able to create a json result like this: {"success":true, "progress":0.2} I suppose the general idea is that, I need a task with interval set to 10sec, ...

How to embed Json result within Extjs Panel?

Hi, I have some issues with Json result and embed it within the html of the Extjs Panel. Here's that I have managed to get so far. myPanel is embedded within a mainPanel, and I have some shows/hide of the myPanel in between other sections of my codes. Ajax request to retrieve Json result like so: Ext.Ajax.request({ url: 'myStore'...

Adding Entity Framework entities (one-to-many) in JSON via ASP.NET WebMethod

I am currently working on a project utilising both the Entity Framework (the version packaged with the .NET Framework version 3.5 SP1) and lots of AJAX-based functionality, which I am implementing using jQuery on the client-side and ASP.NET WebMethods on the server-side. I typically create new entities using a WebMethod that accepts the...

jquery + ajax + json + fill dropdown list not working

Hello, I'm pretty sure i'am almost there....but i cannot figure out how to iterate through json objects and fill a dropdown list. Here is the js code: My JSON data returned:{"name":"County1","name":"County1","name":"County1"} $(document).ready(function() { $("#ddlCountries").change(function() { ...

select_related() and many to many fields with ajax (Django)

I have a simple view that I want to respond to both ajax and regular HTTP requests. Simplified, it looks like this: def tag_search(request, tag): items = Item.objects.filter(tags__tagname__exact=tag) if request.is_ajax(): return HttpResponse(serializers.serialize('json', items), mimetype='application/json') else:...

JQuery: How to PUT JSON via Ajax?

Hi I am trying to put some JSON formatted data via Ajax with JQuery to a server. My code look like this: $.ajax({ type: "PUT", url: myurl, contentType: "application/json", data: {"data": "mydata"} }); But at server-side i receive a data=mydata string, instead of the expected JSON. Firebug tells me the same. Where is ...

JTemplates format Date using asp.net mvc

Hi I have the following JSON date returned from a MVC page e.g. "DateProcessed":"\/Date(1258125238090)\/" and I am using JTemplates to process the data as below. $('#result').setTemplate($("#TemplateResultsTable").html()); $("#result").processTemplate(data); This is my results template <script type="text/html" id="TemplateResults...

How to get key value

Hi, My sample JSON string is as below: {"8776337":{"text":"Test Message","status":"d","created_time":"1244475327","reply_number":"447624800500","completed_time":"1244475373","credits_cost":"0.4"}} "8776337" is dynamic key returned by some APIs. I want to get this key value using LINQ to JSON query. How can I get this key value using...

Is pretty XStream serialization feasible with Scala?

I'm trying out XStream as a way to quickly serialize objects to Xml or JSON to send over the wire, and deserialize. I do want the XML/JSON to be simple/clean. It seems to work well, I've added a few aliases, but now I've hit a problem, this code: println(new XStream.toXML(List(1,2,3))) produces this XML: <scala.coloncolon serializa...

Adding items to a JSON encoded array

Hello I am using this solution found on stackoverflow to encode my MYSQL output to a JSON encoded array. $sth = mysql_query("SELECT ..."); $rows = array(); while($r = mysql_fetch_assoc($sth)) { $rows[] = $r; } print json_encode($rows); This works great and produces an output of [{"id":"81","title":"Something Here","start":...

Json Date to JavasScript Date Conversion problem

Heres the code for converting the json retured date to a string of date. String.toDate = function(stringDate) { var newDate = new Date(parseInt(stringDate.replace("/Date(", "").replace(")/", ""), 10)); return newDate; } Here are the details: Date from the database: 2009-11-18 03:23:25.107 Date Returned by JSON: "/Date(1258514605107)...

Problem deserializing json date on server (asp.net)

Hi, I am currently trying to implement the wonderful jQuery plugin 'week calendar' (here) in my simple asp.net website. I have set up a couple of [WebMethods] to send data to the calendar and to respond to client side events (creating events, modifying events etc). asp.net's automatic serialization of objects when using WebMethods seems...

ASP.NET MVC ControllerBase.Json() fails to generate valid JSON for NHibernate collections

I'm using return Json(whatever); inside an ASP.NET MVC Action to return data to my page via JSON. I'm using jQuery to perform the JSON request and subsequent interaction with DOM. when whatever contains NHibernate objects with collection members (i.e. contains ISet objects), the callback function is never invoked by jQuery. We're using...

storing jquery selectors in an object

The following does not seem to work - IT.TopSlide = { selectors : { div : $('#top-slide'), signup : $('#top-slide #signup'), login : $('#top-slide #login'), signup_trigger : $('#header .top-slide-triggers a.signup-trigger'), login_trigger : $('#header .top-slide-triggers a.login-trigger'), close : $('a.close') }, init :...

jquery json multidimensional array lengths

I'm using a jQuery ajax json call to retrieve a 3 dimensional PHP array into Javascript. the PHP array looks like this: $rate[0][1]['name'] = 'guff'; $rate[0][1]['value'] = 'puff'; $rate[0][2]['name'] = 'guff'; $rate[0][2]['value'] = 'puff'; $rate[0][3]['name'] = 'guff'; $rate[0][3]['value'] = 'puff'; $rate[...

Django ajax formatting convention

What's the correct way to do an ajax request, I've seen people using a returning render_to_string so that they can do all their formatting within python using the template language. eg~ return render_to_string('calendar.html', { 'self' : self, 'month' : self.today.month,}) with this as the javascript: $('#django_calendar_response').h...