Tag: json

Get array value from AJAX request

This question already has an answer here: How do I return the response from an asynchronous call? 22 answers Why is my variable unaltered after I modify it inside of a function? – Asynchronous code reference 6 answers

Decrement ID in JSON array after deletion

I have an array stored in my local storage. It is dynamic. I’m storing the data along with an ID which gets incremented after every entry. User has an option of deleting, hence, I’m supposed to remove the corresponding element from the array. But, I want the ID to remain in ascending order. Ex: var […]

How do you write in JavaScript a empty key from JSON?

Let’s say you have the following JSON object {“”:”some text”} How do you retrieve it in JavaScript? json_in_var={“”:”some text”} alert(json_in_var.) I’m perplexed on this one, any help welcome!

NodeJS request multiple api endpoints

Ok so I am trying to make two or more requests to API endpoints using the request module. I am rendering a HTML file and passing the returned JSON to a handlebars template using the below code: res.render(‘list.html’, { title: ‘List’, data: returnedJSON } I can then iterate over this JSON within my handlebars template […]

While loop won't end when I tell it in JavaScript

var hasData = ‘1’; while (hasData != 0) { $.ajax({ url: ‘/ajax.php?updateRow=’+hasData, dataType: ‘json’, async: false, success: function(data) { hasData = data.next; $(‘.result’).append(data.html); } }); What should happen: JSON Array pulled from PHP ( [html] and [next] ). If [next] is set to 0 (when there are no more entries) – the while loop stops […]

In C# how to encode XML to output it inside JSON in the JavaScript part of a page

I have a handler that uploads a KML file and returns JSON with the KML file as an attribute: context.Response.Write(“{\”name\”:\”” + FileName + “\”,\”type\”:\”” + FileType + “\”,\”size\”:\”” + FileSize + “\”,\”region_id\”:\”” + regionID + “\”,\”kml\”:\”” + HttpUtility.HtmlEncode(xmlData) + “\”}”); As you can see, I’m trying to encode the KML with HttpUtility.HtmlEncode but I get […]

Convert object js display

For example i have object js data = {“dt1_a”: 20, “dt1_b”: 30, “dt2_a”: 40, “dt2_b”: 50} I want convert data to data1 = {“dt1”: {“a”: 20, “b”: 30}, “dt2”: {“a”: 40, “b”: 50}} Please suggest a specific solution.

How to transform JavaScript hashmap?

i’m trying to create a <String, Array()> map from a json object. Imagine i got this json structure: [ { “userId”: “123123”, “password”: “fafafa”, “age”: “21” }, { “userId”: “321321”, “password”: “nana123”, “age”: “34” } ] The map i want to create would be: key (string), value (array) { “userId”: [ “123123”, “321321” ], “password”: […]

Finding my object inside JSON by its ID

[ {“ID”:”5″,”Name”:”Jay”}, {“ID”:”30″,”Name”:”Sharon”}, {“ID”:”32″,”Name”:”Paul”} ] So I have this kind of JSON. I need to easily supply the value for a required key. For example: 30 would yield => “Sharon” 5 would yield => “Jay” etc. What is the right way to do this?

create json object from html table using selected colums using jquery

i was wondering how to parse html table to get json object that i can send via $.post with jquery. i have a table <table id=”Report”> <thead> <tr> <th>Kod</th> <th>Nazwa</th> <th>Ilość</th> <th>Netto / 1szt.</th> <th>Suma brutto</th> </tr> </thead> <tbody> <tr> <td>00171 </td> <td>SŁUP 50/1800 POŚREDNI(P) </td> <td>5</td><td>97.00 PLN </td> <td>394.31 PLN </td> </tr> <tr> <td>00172</td> […]