JQuery getJSON – ajax parseerror

The JSON string you have is an array with 1 object inside of it, so to access the object you have to access the array first. With a json.php that looks like this: [ { “iId”: “1”, “heading”: “Management Services”, “body”: “<h1>Program Overview</h1><h1>January 29, 2009</h1>” } ] I just tried this $.getJSON(“json.php”, function(json) { alert(json[0].body); … Read more

addClass every nth

try $(“ul li:nth-child(3n+1)”).addClass(“A”) $(“ul li:nth-child(3n+2)”).addClass(“B”) $(“ul li:nth-child(3n)”).addClass(“C”) Feel free to consolidate it to make it prettier, but I wanted to expose the selectors.

Renaming object keys recursively

There are a couple of problems there. One is that you’re falling prey to The Horror of Implicit Globals by failing to declare your build variable in the function. But the logic has issues as well, here’s a minimal reworking: var keys_short = [“ch”,”d”,”u”,”tz”]; var keys_long = [“children”,”data”,”user_id”,”time_zone”]; function refit_keys(o){ var build, key, destKey, ix, … Read more

Loading jQuery into chrome-extension

Content scripts will never run in the context of an extension. The correct way to load scripts in your browser action popup is by including it in your code. Let your manifest file be: { “name”: “Test Extension”, “version”: “0.1”, “manifest_version”: 2, “options_page”: “options.html”, “browser_action”: { “default_icon”: “icon.png”, “default_popup”: “popup.html”, “default_title”: “Click me!” } } … Read more

Pass a user defined object to ASP.NET Webmethod from jQuery, using JSON

I quickly set up this project and I was able to successfully call my web method, please adjust your code accordingly. Make sure your class property names are the same as the ones that you pass through JavaScript. Webservice public static Contact getContact(Contact cnt) { cnt.name = “Abijeet Patro”; cnt.phone = “Blah Blah”; return cnt; … Read more

Passing parameters to a page-id in jQuery Mobile

Yes, parameters on the hash are not supported by default. I’ve been using the following plugin to give me that, and it’s been working pretty good so far 😉 jqm.page.params UPDATE – HOW TO USE: I’ve added the following code after including jqm.page.params.js: $(document).bind(“pagebeforechange”, function( event, data ) { $.mobile.pageData = (data && data.options && … Read more