json

Need some help with a custom ASP.NET MVC IExceptionFilter

Hi folks, i'm trying to make my own ExceptionFilter. Out of the box, ASP.NET MVC comes with the [HandleError] attribute. This is great -> but it returns some html error View. As such, I'm wanting to return some json error message. So i'm making my own. Now, everything works great until i test my url. I keep getting an error. this is t...

Make getJSON in JQuery to pass cookies to external domain?

When I use getJSON in JQuery to an external domain the request that is made does not include cookies for that domain. I'm using this for my analytics script that I am writing and I need to set a cookie on the external domain where the script is running so I can track unique visitors. The files domain1.com/website.html <script src...

JSON left out Infinity and NaN; JSON status in ECMAScript?

Any idea why JSON left out NaN and +/- Infinity? It puts Javascript in the strange situation where objects that would otherwise be serializable, are not, if they contain NaN or +/- infinity values. Looks like this has been cast in stone: see RFC4627 and ECMA-262 at the top of p. 197: Finite numbers are stringified as if by String(...

Anyone care to review this JS code for a custom scroller?

Hi Guys I'm by no means a programmer... I've never really taken a comp sci class, don't know much theory, but I still hack together code that usually works. I just don't know how ugly it actually is. I recently wrote this (simple) bit of JS and was wondering I could get some feedback on it... If this isn't an appropriate place for i...

jquery ajax call

I have a question about displaying results using ajax. I have part of the code below. $.ajax({ type: "POST", url: "Service.asmx/GetMethod", data: '{ "field": ' + id, contentType: "application/json; charset=utf-8", dataType: "json", success: function(results) { var html = results.d[0]; $(contentEl...

Does anyone know of a webservice for looking up definitions of words that would be able to return results in JSON?

I found http://words.bighugelabs.com/api.php but nothing like this for definitions/dictionary. Ideally I'd grab a dictionary file and build my own API for this, but this is for a demo and we need something short-term that can be called from within a javascript function. ...

Is there a way to test if a return object JSON length exceeds max length before it throws exception in AJAX.NET?

I am using ajax.net to return an array of records. Some request can be very large and need to be sent with several requests. Is the a way to determine if the json length of an object exceeds the max length before it throws an exception so I can divide the records into smaller returns? ...

How to format some ASP.NET MVC Json result?

Hi folks, i've got a really simple POCO (business) object which I'm returning to the client as some json, using ASP.NET MVC. eg. (please ignore the lack of error checking, etc). public JsonAction Index() { Foo myFoo = MyService(); return Json(myFoo); } kewl. Now, this object includes following public properties... public cl...

How can send back my own 404 error message in ASP.NET , but as json?

Hi folks, i'm trying to send back a simple error message as Json, with the HTTP code as 404. So i started out writing my own IExceptionFilter that checks to see the exception. To keep this simple, if the exception throw is of type ResourceNotFoundException then i set the code to 404. Otherwise everything else if 500. Now, the problem ...

PHP JSON Return String question

I don't know any PHP so another developer helped me out with this code. I am trying to return the names of all the files in a folder on my server. These are then passed to my iPhone app which uses the data. However, I have 160 files in the folder and the JSON string only returns 85. Is there something wrong with this code: <?php $path ...

json Data Output in ASP.NET

I am using the ASP.NET command var returnValue = new JsonResult { Data = items.Skip((pageNumber - 1) * pageSize).Take(pageSize) }; return returnValue; to return the paged contents of a table via JSON, but when I got to try to parse it, in jQuery, the $.each takes each character as an individual element. The output from that is along...

How can I exclude some public properties from being serialized into a JsonResult?

Hi, I have a custom viewmodel which serialized using a JsonResult. The ViewModel has some properties which have to be public, but at the same time these properties should not be visible in the resulting Json output. I've already tried using the [NonSerialized] attribute, but that did not seem to have any effect. Is there any simple w...

Can a JSON object returned by PHP contain a date object

Is there a way to create a JSON object in PHP that contains a javascript date object? Does json_encode automatically convert PHP's DateTime to Javascript's date? ...

How do you protect Web Services when using it as JSON via Jquery?

I currently use asmx for Json transactions using Jquery. How do I protect it from being accessed across other websites and make it exclusive only through my domain? ...

SQL Server CLR Stored Procedure JSON Parameter

Hello, I've come across a scenario where I want to pass a large amount of data to a Stored Procedure for generating some dynamic SQL. The data I want to pass is stored in this Json/C# class object that I use in my ASP.NET MVC web project. [ { "code":"ABC123", "Count": "12998", "Params": [ {"name": "Recent", "value": "0-12...

CakePHP JSON extension?

I've created a simple REST service that serves data as XML. I've managed to enable XML, JS and RSS format but I can not find the way to enable JSON format. Is JS == JSON? Guess not :). How can I enable this in version 1.2/1.3? Thx!! ...

Problem with Json

Im having this weird problem with creating Json dynamically.... for some reason this doesnt work var jsonData = new { total = totalPages, page = page, records = totalRecords, rows = ( from company in companies select new { ...

Getting JSON from Jersey with circular dependencies

Hi I am writing a service that uses Jersey and JAXB. My classes are annotated with @XMLRootElement, @XMLElement, etc. I have a circular dependency between two classes, so I have annotated the circular dependent property with @XMLTransient. So when I call my service I get xml as the default, which works perfectly. However, when I try usi...

How to generate json using php?

Hi, I've never used JSON before and I'm trying to utilize the following javascript: http://jqueryselectcombo.googlecode.com/files/jquery.selectCombo1.2.6.js It needs a JSON output in the following format: [{oV: 'myfirstvalue', oT: 'myfirsttext'}, {oV: 'mysecondvalue', oT: 'mysecondtext'}] Could you guide me to an example on how to gen...

Simple AJAX JS works fine locally in Safari, fails on server and in Firefox (issue with evalJSON())?

I wrote a script that polls Twitter via Prototype's AJAX methods, grabs JSON results, evals them and then updates a div with the formatted tweets. Everything worked fine in testing (Safari 4.0.3 on a OS 10.6.1 machine) until I loaded the script onto a server and it failed. The script had all client side items and referred to the same Pro...