I want to send json formatted data to jQuery.css() function, and i dont know how to do that. Later on, i will send more properties, this is just example of my problem.
//Sorry, this var x is actually string that i get when i print my json string
var x = {"transform":"rotate(30deg)","-o-transform":"rotate(30deg)"}
//If i try to do something like this wont work
$("#mainImage").css(x);
//but following works
$("#mainImage").css({"transform":"rotate(30deg)","-o-transform":"rotate(30deg)"})
It probably has to do something that jquery accepts .css( map )
A map of property-value pairs to set.
And i am trying to send single text string, can i somehow convert json to map ?
@Pekka Yes, i am sure that $("#mainImage").css(x); doesnt work.
@Felix That is what i get by calling json = JSON.stringify(data); sorry if it not json data, i am js newbie..
$("#mainImage").css(x);should work. Are you 100% sure it doesn't?xis not JSON. It is a JavaScript object.