[Solved] How to access property of JavaScript object, given string with property’s name

Let’s look at the code you’re trying to use: $http.get( ‘url’ ) .success(function(data) { var response = angular.fromJson(data); var mobilereceiver=”0147852369″; var messageId = response.ok.mobilereciever; }); You’re very close, in that you recognize that your string mobilereceiver holds the value that needs to be provided as the name of the final property. However, on your last … Read more

[Solved] Pictures in JavaScript

I simple wish to display it in a web browser, so all I need is a line of code which would replace this code in html: <img src=”my/string.jpg” alt=”Mountain View” style=”width:1210px;height:688px”> You can do that with the DOM: You’d use createElement and appendChild or insertBefore: var img = document.createElement(‘img’); img.src = “my/string.jpg”; img.alt = “Mountain … Read more

[Solved] get all children names from object

You could write a simple recursive function that will traverse the contents of your tree: var familyTree = { name: ‘Alex’, children: [ { name: ‘Ricky’, children: [ ] }, { name: ‘John’, children: [ { name: ‘Tom’, children: [ ] } ] } ] }; var traverse = function(tree) { console.log(tree.name); for (var i … Read more

[Solved] Why this mmediately invoked functions is not working properly

First off, I notice two problems: You have a syntax error in the parameter list to $.post You probably don’t want to do this: setTimeout(chatcom_load_one(id), 1000); Here’s an updated version of your code with these errors fixed: function chat_com_one(id) { $(‘#chatcom’).show(‘fast’); (function chatcom_load_one(id) { $.post(‘sendchat2.php’, { option: ‘chatcom_load_one’, tocom: id }, function (data) { $(‘#chatcom … Read more