Home > CRM 2011, JScript > Using JQuery and Json in Ribbon button’s function handler

Using JQuery and Json in Ribbon button’s function handler


  • In one of my CRM 2011 requirement, I had to update a record using ribbon button placed on CRM grid.
  • I had written an update script which calls OData service using Json & JQuery. (link)
  • But when I execute the function, I got “$ undefined” exception.
  • I wondered since I already had “Json.js” & “JQuery.js” web resources added to my entity.
  • After digging deeper, I came to know that, “JQuery.js” web resource is not getting loaded when my ribbon button’s function handler fired.

Fix :-

  • I fixed the problem by loading “JQuery.js” web resource dynamically, before I call my update method.
  • Below is the script to load the web resource’s

    var JScriptWebResourceUrl = “../WebResources/new_JQuery”;

var xmlHttp = new ActiveXObject(“Microsoft.XMLHTTP”);

xmlHttp.open(“GET”, JScriptWebResourceUrl, false);



Hope it helps 🙂

  1. March 10, 2012 at 2:54 PM

    Thanks you 🙂

  2. Regardy
    March 30, 2012 at 9:13 PM

    thank you very much!

  3. Rameswar Datt
    July 30, 2012 at 3:48 PM

    Thanks Rajeev!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: