json

JavaScript: Keeping track of eventListeners on DOM elements

What is the best way to keep track of eventListener functions on DOM elements? Should I add a property to the element which references the function like this: var elem = document.getElementsByTagName( 'p' )[0]; function clickFn(){}; elem.listeners = { click: [clickFn, function(){}] }; elem.addEventListener( 'click', function(e){ clickFn...

Printing of JSON output fails with PHP

Hello! I am trying to build a news reader that is using the Bing News API. When I am using a keyword that does not use special characters the result displays fine on the page but if I use for example Ö I get errors, BUT if I save the results (because the API delivers fine results even when using Ö) in a local file and use that to print ...

Problem with Json Date format when calling cross-domain proxy

I am using a proxy service to allow my client side javascript to talk to a service on another domain The proxy is a simple ashx file with simply gets the request and forwards it onto the service on the other domain : using (var sr = new System.IO.StreamReader(context.Request.InputStream)) { requestData = sr....

Jquery AutoComplete Load Problem

Hi all; Not Work Jquery Code: $('[id$=Name]').autocomplete('CallBack.aspx',{formatItem: function(item){return item.Name;}}).result(function(event, item) { location.href = item.AGE; }); Json: var data = [{NAME:"John",AGE:"57"}]; Work Jquery Code: var data = [{NAME:"John",AGE:"57"}]; $('[id$=Name]').autoco...

How Can we Show Data in a View By passing a jsonResult?

How Can we Show Data in a View By passing a jsonResult? any article related this please send the link? ...

jQuery $.ajax Not Working in IE8 but it works on FireFox & Chrome

I have the following ajax call which works perfectly in Firefox and Chrome but not IE: function getAJAXdates( startDate, numberOfNights, opts ) { var month = startDate.getMonth() + 1; var day = startDate.getDate(); var year = startDate.getFullYear(); var d = new Date(); var randNum = Math.f...

Select Options from JSON

I am a newb when it comes to JSON and am wanting to try to write a JSON select option autofiller, but do not know where to start. The way my script works currently is using PHP and MySQL to fill the first set of select options with a distinct list from a DB table and then upon a user selection the next set of select options are autofil...

Is JSON.stringify() reliable for serializing JSON objects?

I need to send full objects from Javascript to PHP. It seemed pretty obvious to do JSON.stringify() and then json_decode() on the PHP end, but will this allow for strings with ":" and ","? Do I need to run an escape() function on big user input strings that may cause an issue? What would that escape function be? I don't think escape ...

Creating DOM elements on the fly - check if the data is not harmful

I already posted a question closely related to the this one. I watched the Mix10 video with P. Haacked and S. Hanselman. I am building an AJAX-powered site whose input forms are created on the fly. All the code to accomplish this is done within a script tag or a javascript file. For example the following DOM elements are created when t...

Accessing Remote ASP.NET Web Services' JSON data

How can I best create a webservice method which returns JSON data that is to be consumed by an application on a different domain? The following article talks about how to set it up: http://www.codeproject.com/KB/webservices/ASPNET_JSONP.aspx I havent tried it out yet but it seems like there are a lot of steps and the ajax client has to...

getjson jquery parsing an array

Got the simplified array working see below Following up on the complicated array to parse see here. TLDR: Want to get each heading from an array and insert it into a div without knowing what is inside the div using Jquery - getJSON. Edit: The data is coming from a piece of software that is outputting the JSON string every couple of ...

json_pure/rubygems cyclic dependencies

I have an issue when trying to set up rvm, where gems weren't installing due to them being dependent on json_pure. I tried to install json_pure, but rubygems itself seems to depend on json_pure. I have tried removing all versions of json_pure, but rubygems still complains. $ sudo gem install json_pure /Library/Ruby/Site/1.8/rubygems....

Different approaches to submitting forms with Ajax

Hi! In the past whilst working with AJAX-submitted forms, I have always created the forms in HTML and used the forms own POST function to submitting the actual data to a specific url. - This far is everything is the same as any non-AJAX form. From that point I have used the jQuery Form plugin together with some basic jQuery code to rem...

Call any webservice from the same $.ajax() call

Hi! Im creating a usercontrol which is controled client side, it has an javascript-file attatched to it. This control has a button and upon click a popup appears, this popup shows a list of my domain entities. My entities are fetched using a call to a webservice. Im trying to get this popup usercontrol to work on all my entities, there...

Passing a web service an unknown number of parameters

I'm relatively new to utilizing web services. I'm trying to create one that will be accepting data from a ASP.Net form whose input controls are created dynamically at runtime and I don't how many control values will be getting passed. I'm thinking I'll be using jQuery's serialize() on the form to get the data, but what do I have the ...

ExtJS JsonStore partially loads data in IE6 and fails

I have a JsonStore used by a ComboBox, and in IE6 it only partially loads the JSON. It cuts off after a point, which causes the JsonStore to fail. In FF and Chrome this works fine, and it even works if I run Fiddler.. I'm using ExtJS 3.2.0 and the webserver is a .Net Development server (vs2008) and runs locally. I've also found that ...

file_get_contents("php://input") or $HTTP_RAW_POST_DATA, which one is better to get the body of JSON request?

And from the client side, which request type (GET or POST) is better to use, to send JSON data if I use XmlHTTPRequest? My application use this stream of data for either retrive data form database and execute some functionality in PHP. EDIT: My question was inspired from this answer: http://stackoverflow.com/questions/813487/how-to-pos...

JSON stringify standalone function for JavaScript

I know of YUI who has a JSON.stringify utility and also of JSON2 from json.org. What are other good implementations of JSON.stringify? It should also work in IE6, IE7 and not depend on a framework. If it depends on anything this should be easily included all in one file. Edit: I could easily use jquery-json, which was suggested in t...

Update JQuery Progressbar with JSON Response in an ajax Request

All, I have an AJAX request, which makes a JSON request to a server, to get the sync status. The JSON Request and responses are as under: I want to display a JQuery UI progressbar and update the progressbar status, as per the percentage returned in the getStatus JSON response. If the status is "insync", then the progressbar should not a...

How can I put double quotes inside a string within an ajax JSON response from php?

I receive a JSON response in an Ajax request from the server. This way it works: { "a" : "1", "b" : "hello 'kitty'" } But I did not succeed in putting double quotes around kitty. When I convert " to \x22 in the Ajax response, it is still interpreted as " by JavaScript and I cannot parse the JSON. Should I also escape the \ and unesc...