console.log(result) returns [object Object]. How do I get result.name? [duplicate]

This question already has answers here: How to return the response from an asynchronous call (43 answers) Closed 5 years ago. My script is returning [object Object] as a result of console.log(result). Can someone please explain how to have console.log return the id and name from result? $.ajaxSetup({ traditional: true }); var uri = “”; … Read more

How to merge 2 JSON objects from 2 files using jq?

I’m using the jq tools (jq-json-processor) in shell script to parse json. I’ve got 2 json files and want to merge them into one unique file Here the content of files: file1 { “value1”: 200, “timestamp”: 1382461861, “value”: { “aaa”: { “value1”: “v1”, “value2”: “v2” }, “bbb”: { “value1”: “v1”, “value2”: “v2” }, “ccc”: { … Read more

Why does the PHP json_encode function convert UTF-8 strings to hexadecimal entities?

I have a PHP script that deals with a wide variety of languages. Unfortunately, whenever I try to use json_encode, any Unicode output is converted to hexadecimal entities. Is this the expected behavior? Is there any way to convert the output to UTF-8 characters? Here’s an example of what I’m seeing: INPUT echo $text; OUTPUT … Read more

POST JSON fails with 415 Unsupported media type, Spring 3 mvc

I am trying to send a POST request to a servlet. Request is sent via jQuery in this way: var productCategory = new Object(); productCategory.idProductCategory = 1; productCategory.description = “Descrizione2”; newCategory(productCategory); where newCategory is function newCategory(productCategory) { $.postJSON(“ajax/newproductcategory”, productCategory, function( idProductCategory) { console.debug(“Inserted: ” + idProductCategory); }); } and postJSON is $.postJSON = function(url, data, … Read more

JWT vs cookies for token-based authentication

I read some posts about “JWT vs Cookie” but they only made me more confused… I want some clarification, when people talking about “token-based authentication vs cookies”, cookies here merely refer to session cookies? My understanding is that cookie is like a medium, it can be used to implement a token-based authentication(store something that can … Read more

Basic example of using .ajax() with JSONP?

Please could someone help me work out how to get started with JSONP? Code: $(‘document’).ready(function() { var pm_url=”http://twitter.com/status”; pm_url += ‘/user_timeline/stephenfry.json’; pm_url += ‘?count=10&callback=photos’; var photos = function (data) { alert(data); }; $.ajax({ url: pm_url, dataType: ‘jsonp’, jsonpCallback: ‘photos’, jsonp: false, }); }); Fiddle: http://jsfiddle.net/R7EPt/6/ Should produce an alert, as far as I can work … Read more