Search Results

Search found 5623 results on 225 pages for 'mr json'.

Page 8/225 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • iPhone JSON Object

    - by Cosizzle
    Hello, I'm trying to create a application that will retrieve JSON data from an HTTP request, send it to a the application main controller as a JSON object then from there do further processing with it. Where I'm stick is actually creating a class that will serve as a JSON class in which will take a URL, grab the data, and return that object. Alone, im able to make this class work, however I can not get the class to store the object for my main controller to retrieve it. Because im fairly new to Objective-C itself, my thoughts are that im messing up within my init call: -initWithURL:(NSString *) value { responseData = [[NSMutableData data] retain]; NSString *theURL = value; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:theURL]]; [[NSURLConnection alloc] initWithRequest:request delegate:self]; return self; } The processing of the JSON object takes place here: - (void)connectionDidFinishLoading:(NSURLConnection *)connection { [connection release]; NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; [responseData release]; NSError *jsonError; SBJSON *json = [[SBJSON new] autorelease]; NSDictionary *parsedJSON = [json objectWithString:responseString error:&jsonError]; // NSArray object. listings = [parsedJSON objectForKey:@"posts"]; NSEnumerator *enumerator = [listings objectEnumerator]; NSDictionary* item; // to prove that it does work. while (item = (NSDictionary*)[enumerator nextObject]) { NSLog(@"posts:id = %@", [item objectForKey:@"id"]); NSLog(@"posts:address = %@", [item objectForKey:@"address"]); NSLog(@"posts:lat = %@", [item objectForKey:@"lat"]); NSLog(@"posts:lng = %@", [item objectForKey:@"lng"]); } [responseString release]; } Now when calling the object within the main controller I have this bit of code in the viewDidLoad method call: - (void)viewDidLoad { [super viewDidLoad]; JSON_model *jsonObj = [[JSON_model alloc] initWithURL:@"http://localhost/json/faith_json.php?user=1&format=json"]; NSEnumerator *enumerator = [[jsonObj listings] objectEnumerator]; NSDictionary* item; // while (item = (NSDictionary*)[enumerator nextObject]) { NSLog(@"posts:id = %@", [item objectForKey:@"id"]); NSLog(@"posts:address = %@", [item objectForKey:@"address"]); NSLog(@"posts:lat = %@", [item objectForKey:@"lat"]); NSLog(@"posts:lng = %@", [item objectForKey:@"lng"]); } }

    Read the article

  • Java - JSON Null Exception

    - by user1112111
    Hi, I'm using JSON to deserialize an input string that contains a null value for certain hashmap property. Does anyone have any clue why this exception occurs ? Is it possible that null is not accepted as a value Is this configurable somehow ? input sample: {"prop1":"val1", "prop2":123, "prop3":null} stacktrace: net.sf.json.JSONException: null object at net.sf.json.JSONObject.verifyIsNull(JSONObject.java:2856) at net.sf.json.JSONObject.isEmpty(JSONObject.java:2212) Thanks.

    Read the article

  • Rails escape_javascript creates invalid JSON by escaping single quotes

    - by Arrel
    The escape_javascript method in ActionView escapes the apostrophe ' as backslash apostrophe \', which gives errors when parsing as JSON. For example, the message "I'm here" is valid JSON when printed as: {"message": "I'm here"} But, <%= escape_javascript("I'm here") %> outputs "I\'m here", resulting in invalid JSON: {"message": "I\'m here"} Is there a patch to fix this, or an alternate way to escape strings when printing to JSON?

    Read the article

  • ASP.Net JSON Web Service Post Form Data

    - by Will D
    I have a ASP.NET web service decorated with System.Web.Script.Services.ScriptService() so it can return json formatted data. This much is working for me, but ASP.Net has a requirement that parameters to the web service must be in json in order to get json out. I'm using jquery to run my ajax calls and there doesn't seem to be an easy way to create a nice javascript object from the form elements. I have looked at serialiseArray in the json2 library but it doesn't encode the field names as property name in the object. If you have 2 form elements like this <input type="text" name="namefirst" id="namefirst" value="John"/> <input type="text" name="namelast" id="namelast" value="Doe"/> calling $("form").serialize() will get you the standard query string namefirst=John&namelast=Doe calling JSON.stringify($("form").serializeArray()) will get you the (bulky) json representation [{"name":"namefirst","value":"John"},{"name":"namelast","value":"Doe"}] This will work when passing to the web service but its ugly as you have to have code like this to read it in: Public Class NameValuePair Public name As String Public value As String End Class <WebMethod()> _ Public Function GetQuote(ByVal nvp As NameValuePair()) As String End Function You would also have to wrap that json text inside another object nameed nvp to make the web service happy. Then its more work as all you have is an array of NameValuePair when you want an associative array. I might be kidding myself but i imagined something more elegant when i started this project - more like this Public Class Person Public namefirst As String Public namelast As String End Class which would require the json to look something like this: {"namefirst":"John","namelast":"Doe"} Is there an easy way to do this? Obviously it is simple for a form with two parameters but when you have a very large form concatenating strings gets ugly. Having nested objects would also complicate things The cludge I have settled on for the moment is to use the standard name value pair format stuffed inside a json object. This is compact and fast {"q":"namefirst=John&namelast=Doe"} then have a web method like this on the server that parses the query string into an associate array. <WebMethod()> _ Public Function AjaxForm(ByVal q As String) as string Dim params As NameValueCollection = HttpUtility.ParseQueryString(q) 'do stuff return "Hello" End Sub As far a cludges go this one seems reasonably elegant in terms of amount of code, but my question is: is there a better way? Is there a generally accepted way of passing form data to asp.net web/script services?

    Read the article

  • JSON and WebOS simple example?

    - by user558361
    I have been following this tutorial http://tinyurl.com/327p325 which has been GREAT up until this point where I can't get his code to work. I get the list working with static items but I can't get it to work with the json items. I've tried to simplify it with what I really want it to do to try and debug what is wrong (also if someone could please tell me how to view the Mojo log that would be awesome) In the tutorial he has to use the yahoo service to convert the site into json data, while the site I want to interact with already has json data generated so this is what I have PageAssistant.prototype.setup = function() { this.myListModel = { items : [] }; this.myListAttr = { itemTemplate: "page/itemTemplate", renderLimit: 20, }; this.controller.setupWidget("MyList",this.myListAttr,this.myListModel); this.controller.setupWidget("search_divSpinner", { spinnerSize : "large" }, { spinning: true } ); }; PageAssistant.prototype.activate = function(event) { this.getData(); }; PageAssistant.prototype.getData = function () { // the spinner doesn't show up at all $("search_divScrim").show(); var url = "http://www.website.com/.json"; var request = new Ajax.Request(url, { method: 'get', asynchronous: true, evalJSON: "false", onSuccess: this.parseResult.bind(this), on0: function (ajaxResponse) { // connection failed, typically because the server is overloaded or has gone down since the page loaded Mojo.Log.error("Connection failed"); }, onFailure: function(response) { // Request failed (404, that sort of thing) Mojo.Log.error("Request failed"); }, onException: function(request, ex) { // An exception was thrown Mojo.Log.error("Exception"); }, }); } PageAssistant.prototype.parseResult = function (transport){ var newData = []; var theStuff=transport.responseText; try { var json = theStuff.evalJSON(); } catch(e) { Mojo.Log.error(e); } // this is where I believe I am wrong for (j=0;j < json.data.count;j++) { var thread=json.data.children[j]; newData[j] = { title: thread.data.author }; } this.myListModel["items"] = newData; this.controller.modelChanged(this.myListModel , this); $("search_divScrim").hide(); } So where I commented that I believe I am wrong I am just trying to get the title out of this json data { kind: Listing data: { children: [ { kind: food data: { author: Foodmaster hidden: false title: You should eat this } }, // then it repeats with the kind: and data Anyone see where I went wrong? I would like to know how to view the log as I have log events but can't figure out where to look to see if any of them are being thrown.

    Read the article

  • Generating JSON request manually, returned HTML causing issues.

    - by mrblah
    Hi, I am generating my JSON manually, and I even escaped for quotes with a preceding backslash. It is causing me problems. My HTML returned looks something like: <div class="blah"><div class="a2">This is just a test! I hope this work's man!</div></div> string json = "MY HTML HERE"; json = json.Replace(@"""", @"\"""); Is there more to replace than just the double quotes?

    Read the article

  • Struts:JSON:return multiple objects

    - by cp
    Hello Is it possible to return multiple JSON objects in the request header with Struts1? I am presently returning a single JSON objects, however the need now is to return a second data structure. All the client-side processing works perfectly for the single data structure in the single JSON objects, I really do not want to complicate it by putting two hetrogenous data structures in a single return JSON object. tia.

    Read the article

  • Generic JSON parser in .NET / WPF?

    - by niklassaers
    I've read lots of tutorials on how to deserialize a JSON object to an object of a particular using DataContractJsonSerializer. However, I'd like to deserialize my object to a Dictionary consisting of either Strings, Arrays or Dictionaries, such as System.Json does with SilverLight when I say JsonObject.Parse(myJSONstring). Is there an equivalent to System.Json that I can use in my WPF project? (just a short background: I'm fetching JSON objects that have way to much info, and I just want to use a little bit to fill out a String array) Cheers Nik

    Read the article

  • populate CoreData data model from JSON files prior to app start

    - by johannes_d
    I am creating an iPad App that displays data I got from an API in JSON format. My Core Data model has several entities(Countries, Events, Talks, ...). For each entity I have one .json file that contains all instances of the entity and its attributes as well as its relationships. I would like to populate my Core Data data model with these entities before the start of the App (otherwise it takes about 15 minutes for the iPad to create all the instances of the entities from the several JSON files using factory methods). I am currently importing the data into CoreData like this: -(void)fetchDataIntoDocument:(UIManagedDocument *)document { dispatch_queue_t dataQ = dispatch_queue_create("Data import", NULL); dispatch_async(dataQ, ^{ //Fetching data from application bundle NSURL *tedxgroupsurl = [[NSBundle mainBundle] URLForResource:@"contries" withExtension:@"json"]; NSURL *tedxeventsurl = [[NSBundle mainBundle] URLForResource:@"events" withExtension:@"json"]; //converting the JSON files to NSDictionaries NSError *error = nil; NSDictionary *countries = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfURL:countriesurl] options:kNilOptions error:&error]; countries = [countries objectForKey:@"countries"]; NSDictionary *events = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfURL:eventsurl] options:kNilOptions error:&error]; events = [events objectForKey:@"events"]; //creating entities using factory methods in NSManagedObject Subclasses (Country / Event) [document.managedObjectContext performBlock:^{ NSLog(@"creating countries"); for (NSDictionary *country in countries) { [Country countryWithCountryInfo:country inManagedObjectContext:document.managedObjectContext]; //creating Country entities } NSLog(@"creating events"); for (NSDictionary *event in events) { [Event eventWithEventInfo:event inManagedObjectContext:document.managedObjectContext]; // creating Event entities } NSLog(@"done creating, saving document"); [document saveToURL:document.fileURL forSaveOperation:UIDocumentSaveForOverwriting completionHandler:NULL]; }]; }); dispatch_release(dataQ); } This combines the different JSON files into one UIManagedDocument which i can then perform fetchRequests on to populate tableViews, mapView, etc. I'm looking for a way to create this document outside my application & add it to the mainBundle. Then I could copy it once to the apps DocumentsDirectory and be able I use it (instead of creating the Document within the app from the original JSON files). Any help is appreciated!

    Read the article

  • Is JSON array parsable?

    - by Alex
    I have a YQL query that extracts data from a page and returns it to my script as JSON. The JSON is huge, and as such, here's my question: Is JSON array parsable? So that I can iterate over the entire JSON structure?

    Read the article

  • Unable to fetch Json data from remote url

    - by user3772611
    I am cracking my head to solve this thing. I am unable to fetch the JSON data from remote REST API. I need to fetch the JSOn data nd display the "html_url" field from the JSON data on my website. I saw that you need the below charset and content type for fetching JSON. <html> <head> <meta charset="utf-8"> <meta http-equiv="content-type" content="application/json"> </head> <body> <p>My Instruments page</p> <ul></ul> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script> <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script> <script type="text/javascript"> $(document).ready(function () { alert("Inside the script"); $.getJSON(" https://pki.zendesk.com/api/v2/help_center/sections/200268985/articles.json", function (obj) { alert("Inside the getJSON"); $.each(obj, function (key, value) { $("ul").append("<li>" + value.html_url + "</li>"); }); }); }); </script> </body> </html> I referred to following example on jsfiddle http://jsfiddle.net/2xTjf/29/ The "http://date.jsontest.com" given in this example also doesn't work in my code. The first alert is pops but not the other one. I am a novice at JSON/ Jquery. i used jsonlint.com to find if it has valid JSON, it came out valid. I tested using chrome REST client too. What am I missing here ? Help me please ! Thanks in anticipation.

    Read the article

  • Chef: Load Attributes from encrypted databag in json role

    - by jcvj
    I'm want to use the postfix cookbook for chef. The sasl password is expected to be in an attribute. So usually you would do this: "default_attributes": { "postfix": { "sasl": { "smtp_sasl_passwd": "somepassword" } } } The thing is: I don't want to have the password in the repository in plain text. So I put it in an encrypted data bag. Now I want to access it. This can be done with this: Chef::EncryptedDataBagItem.load("passwords", "postfix")['password'] The problem: This only works in a .rb file, but my role is in json; all my roles are in json! I don't want to change that just for this purpose. Does anybody have an idea what to do here? Help is very appreciated.

    Read the article

  • Why I am getting type error undefined from my jquery from my php json?

    - by Brained Washed
    I don't know what is wrong is am I just missing something, all my expected data is successfully receive based on firebug' console tab the problem is displaying the data. Here's my jquery code: success: function(data){ var toAppend = ''; if(typeof data === "object"){ for(var i=0;i<data.length;i++){ toAppend += '<tr><td colspan="2">'+data[i]['main-asin'][0]+'</td></tr>'; toAppend += '<tr><td>'+data[i]['sub-asin'][0]+'</td><td></td></tr>'; } $('.data-results').append(toAppend); } } Here's my php code: foreach($xml->Items->Item as $item){ $items_from_amazon[] = array('main-asin'=>$item->ASIN); foreach($xml->Items->Item->Variations->Item as $item){ $items_from_amazon[] = array('sub-asin'=>$item->ASIN); } } echo json_encode($items_from_amazon); //return amazon products And here's the result from my firebug:

    Read the article

  • Put/Post json not working with ODataController if Model has Int64

    - by daryl
    I have this Data Object with an Int64 column: [TableAttribute(Name="dbo.vw_RelationLineOfBusiness")] [DataServiceKey("ProviderRelationLobId")] public partial class RelationLineOfBusiness { #region Column Mappings private System.Guid _Lineofbusiness; private System.String _ContractNumber; private System.Nullable<System.Int32> _ProviderType; private System.String _InsuredProviderType; private System.Guid _ProviderRelationLobId; private System.String _LineOfBusinessDesc; private System.String _CultureCode; private System.String _ContractDesc; private System.Nullable<System.Guid> _ProviderRelationKey; private System.String _ProviderRelationNbr; **private System.Int64 _AssignedNbr;** When I post/Put object through my OData controller using HttpClient and NewtsonSoft: partial class RelationLineOfBusinessController : ODataController { public HttpResponseMessage PutRelationLineOfBusiness([FromODataUri] System.Guid key, Invidasys.VidaPro.Model.RelationLineOfBusiness entity) the entity object is null and the error in my modelstate : "Cannot convert a primitive value to the expected type 'Edm.Int64'. See the inner exception for more details." I noticed when I do a get on my object using the below URL: Invidasys.Rest.Service/VidaPro/RelationLineOfBusiness(guid'c6824edc-23b4-4f76-a777-108d482c0fee') my json looks like the following - I noticed that the AssignedNbr is treated as a string. { "odata.metadata":"Invidasys.Rest.Service/VIDAPro/$metadata#RelationLineOfBusiness/@Element", "Lineofbusiness":"ba129c95-c5bb-4e40-993e-c28ca86fffe4","ContractNumber":null,"ProviderType":null, "InsuredProviderType":"PCP","ProviderRelationLobId":"c6824edc-23b4-4f76-a777-108d482c0fee", "LineOfBusinessDesc":"MEDICAID","CultureCode":"en-US","ContractDesc":null, "ProviderRelationKey":"a2d3b61f-3d76-46f4-9887-f2b0c8966914","ProviderRelationNbr":"4565454645", "AssignedNbr":"1000000045","Ispar":true,"ProviderTypeDesc":null,"InsuredProviderTypeDesc":"Primary Care Physician", "StartDate":"2012-01-01T00:00:00","EndDate":"2014-01-01T00:00:00","Created":"2014-06-13T10:59:33.567", "CreatedBy":"Michael","Updated":"2014-06-13T10:59:33.567","UpdatedBy":"Michael" } When I do a PUT with httpclient the JSON is showing up in my restful services as the following and the json for the AssignedNbr column is not in quotes which results in the restful services failing to build the JSON back to an object. I played with the JSON and put the AssignedNbr in quotes and the request goes through correctly. {"AssignedNbr":1000000045,"ContractDesc":null,"ContractNumber":null,"Created":"/Date(1402682373567-0700)/", "CreatedBy":"Michael","CultureCode":"en-US","EndDate":"/Date(1388559600000-0700)/","InsuredProviderType":"PCP", "InsuredProviderTypeDesc":"Primary Care Physician","Ispar":true,"LineOfBusinessDesc":"MEDICAID", "Lineofbusiness":"ba129c95-c5bb-4e40-993e-c28ca86fffe4","ProviderRelationKey":"a2d3b61f-3d76-46f4-9887-f2b0c8966914", "ProviderRelationLobId":"c6824edc-23b4-4f76-a777-108d482c0fee","ProviderRelationNbr":"4565454645","ProviderType":null, "ProviderTypeDesc":null,"StartDate":"/Date(1325401200000-0700)/","Updated":"/Date(1408374995760-0700)/","UpdatedBy":"ED"} The reason we wanted to expose our business model as restful services was to hide any data validation and expose all our databases in format that is easy to develop against. I looked at the DataServiceContext to see if it would work and it does but it uses XML to communicate between the restful services and the client. Which would work but DataServiceContext does not give the level of messaging that HttpRequestMessage/HttpResponseMessage gives me for informing users on the errors/missing information with their post. We are planning on supporting multiple devices from our restful services platform but that requires that I can use NewtonSoft Json as well as Microsoft's DataContractJsonSerializer if need be. My question is for a restful service standpoint - is there a way I can configure/code the restful services to take in the AssignedNbr as in JSON as without the quotes. Or from a JSON standpoint is their a way I can get the JSON built without getting into the serializing business nor do I want our clients to have deal with custom serializers if they want to write their own apps against our restful services. Any suggestions? Thanks.

    Read the article

  • How to convert XML to JSON in Python?

    - by Geuis
    I'm doing some work on App Engine and I need to convert an XML document being retrieved from a remote server into an equivalent JSON object. I'm using xml.dom.minidom to parse the XML data being returned by urlfetch. I'm also trying to use django.utils.simplejson to convert the parsed XML document into JSON. I'm completely at a loss as to how to hook the two together. Below is the code I more or less have been tinkering with. If anyone can put A & B together, I would be SO greatful. I'm freaking lost. from xml.dom import minidom from django.utils import simplejson as json #pseudo code that returns actual xml data as a string from remote server. result = urlfetch.fetch(url,'','get'); dom = minidom.parseString(result.content) json = simplejson.load(dom) self.response.out.write(json)

    Read the article

  • Jquery JQGrid breaks when contentType=application/json?

    - by JK
    I've had to use $.ajaxSetup() to globally change the contentType to application/json $.ajaxSetup({ contentType: "application/json; charset=utf-8" }); (See this question for why I had to use application/json http://stackoverflow.com/questions/2792603/aspnet-mvc-why-is-modelstate-isvalid-false-the-x-field-is-required-when-that) But this breaks the jquery jqrid with this error: Invalid JSON primitive: _search The POST data it is trying to send is: _search=false&nd=1274042681880&rows=20&page=1&sidx=&sord=asc Which of is not in json format, so of course it fails. Is there anyway to tell jqrid what contenttype to use? I have searched on the jqrid wiki, but doesn't have much documentation about anything really. http://www.trirand.com/jqgridwiki/doku.php?do=search&id=contenttype&fulltext=Search

    Read the article

  • JSON on IE6 (IE7)

    - by David Thorisson
    Sorry for my inpatience but after weeks staying up late and just having put my web online, I just don't have any left energy to debug... I just can't Google how to implement JSON on IE6 & IE7... I'm using JSON.stringify(...) From what I understand JSON is not built in on IE6-7 and has to be dynamically added in in-line code... how do you do that? I already have jQuery - is it my correct understanding that their JSON engine relies on the browser native one? Then some comment on invalid JSON code that makes IE6-7 fail, but I thought it wasn't native in IE6-7? Anyone?

    Read the article

  • Serialize .Net object to json, controlled using xml attributes

    - by sprocketonline
    I have a .Net object which I've been serializing to Xml and is decorated with Xml attributes. I would now like to serialize the same object to Json, preferably using the Newtonsoft Json.Net library. I'd like to go directly from the .Net object in memory to a Json string (without serializing to Xml first). I do not wish to add any Json attributes to the class, but instead would like for the Json serializer use the existing Xml attributes. [XmlRoot("hello")] public class world{ [XmlIgnore] public int ignoreMe{ get; } [XmlElement("foo")] public int bar{ get; } [XmlElement("marco")] public int polo{ get; } } becomes "hello":{ "foo":0, "marco":0 }

    Read the article

  • JSON htmlentities javascript

    - by Wessel Rossing
    Hi! I am using an XMLHttpRequest to POST a JSON string to PHP. The JSON object is created in JavaScript and using the JSON2.js from json.org to create an JSON string representing the object. JSON.stringify(object); Whenever the object contains a string which has a special character in it, e.g. é, JavaScript does not give any error but PHP receives an empty array [] Is there a JavaScript function which produces the exact same resutls as the PHP function htmlentities() The data is send via POST, so the following functions escape() encodeURI() encodeURIComponent() are a bit overkill. Thanks!

    Read the article

  • List of objects to JSON to Html Table?

    - by DaveDev
    If I have a list of objects IEnumerable<MyType> myTypes; Is it possible for me to return this to the client as JSON return Json(myTypes); and if so, is it possible for me to convert this (now JSON format) list to a when it gets to the client? Is there any jQuery plugin to do this? The thing is, there's loads of other stuff I need to send as JSON also, so generating a table with a PartialView and embedding that into the JSON is a extra complexity that I'd like to avoid. Thanks.

    Read the article

  • rendering JSON in GRAILS with part of the attributes of an object

    - by bsreekanth
    Hello, I am trying to build JSON from two fields. Say, I have a list of object(party), and I only need to pass 2 items as JSON pair. def list = getMyList() //it contains 2 party objects partyTo = array { for (i in list) { x partyId: i.id y partyName: i.toString() } } The JSON string is {"partyTo":[ {"partyId":12}, {"partyName":"Ar"}, {"partyId":9}, {"partyName":"Sr"} ] } when I extract it at the client, it is treated as 4 objects. I wanted as 2 objects, with the below format. {"partyTo":[ {"partyId":12 , "partyName":"Ar"}, {"partyId":9 , "partyName":"Sr"} ] } I'm getting 4 objects, probably because I use an array to build JSON. I'm new to groovy and JSON, so not sure about the right syntax combinations. Any help highly appreciated. thanks.

    Read the article

  • Need to preserve order of elements sent in JSON from Java

    - by Kush
    I'm using JSON.org APIs for Java to use JSON in my JSP webapp, I know JSONObject doesn't preserve order of elements the way they are put into it and one has to use JSONArray for that but I don't know how to use it since I need to send key and value both as received from the database, and here I'm sending data to jQuery via JSON where I need the order of data to be maintained. Following is my servlet code, where I'm getting results from the database using ORDER BY and hence I want the order to be exact as returned from the database. Also this JSON object requested using $.post method of jQuery and is used to populate dropdown on reciever page. ResultSet rs = st.executeQuery("SELECT * FROM tbl_state order by state_name"); JSONObject options = new JSONObject(); while(rs.next()) options.put(rs.getString("state_id"),rs.getString("state_name")); response.setContentType("application/json"); response.setCharacterEncoding("UTF-8"); response.getWriter().write(options); Thanks.

    Read the article

  • jQuery ajaxForm returning .json file

    - by Lowgain
    I've got a model creation form in rails which I also have returning JSON through ajax. My code so far look like: $('#new_stem').ajaxForm({ //#new_stem is my form dataType: 'json', success: formSuccess }); function formSuccess(stemObj) { //does stuff with stemObj } And I have a multipart form with a file uploader (but I'm not sure if that is relevant). When I submit the form it works fine (my models are properly being created and renders as json), but instead of the json getting handled by the formSuccess function, it prompts a download for "stems.json" (the path to my stem creation action) in Firefox. What would cause this to happen, and what could solve it? Not sure if this is part of the problem, but I don't have a submit button in my form, I have a link with a click handler that calls $('#new_stem).submit() Thanks guys!

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >