0

I know, I know, "JS" in JSON and "j" in jQuery stands for JavaScript. Feel free to edit the title if you find a better formulation.

When I type in the URL "http://beep-beep" in my browser, I get a nicely formatted JSON file containing "{sound: 'beep', occurence: 2}", meaning the web service works as supposed to. Then I thought to myself: let's do that in CRM, in onLoad function for the creation of an entity. So, I'm trying to execute the following, copied directly from the SDK.

alert("Commence.");

$.ajax({
  type: "POST",
  url: "http://beep-beep",
  data: "{}",
  contentType: "application/json; charset=utf-8",
  dataType: "json",
  success: function (msg) {
    alert("Yippi!");
  }
});

alert("Finish.");

However, the code crashes telling me that "$" is not a defined symbol. Isn't jQuery an integral part of CRM JavaScript engine?! What am I missing here? Is there an easier way to consume a JSON feed?

6
  • @BenCameron Good guess! My jQuery isn't there... How does one refer it in a web resource in CRM 2011?! I've typed alert($); to see if I get null. And I got null. I was under impression that jQuery was an integral part of CRM 2011 by default... Commented Nov 6, 2012 at 16:22
  • I'm not sure about CRM but can you add an include in a masterpage or something similar? Commented Nov 6, 2012 at 16:24
  • 1
    Possible duplicate: CRM 2011 “$ is undefined” Commented Nov 6, 2012 at 16:26
  • @BenCameron Hehe, I'm only permitted to create a JS file and upload it to the server. No HTML, no MASTER, no nothin'. I've grade you up - good shot. But it didn't solved my problem (yet). :) I think Peter just gave me something to bite on. Apparently I was mistaken - no jQuery by default. I can try adding it as a web resource. All I really need is access to the JSON web service so it feels like a bit of overkill, but hey, as long as it works... Commented Nov 6, 2012 at 16:27
  • 1
    Ok, you've got a CRM 2011 issue now. I can't help you out with that. At least you know whats going wrong though. Good luck! Commented Nov 6, 2012 at 16:30

3 Answers 3

2

Have you included the jquery lib? Are you having the same issue as this... Object Expected error, javascript, jQuery

Sign up to request clarification or add additional context in comments.

2 Comments

Indeed we have. This is the longest someone ever has waited until asking me to accept an answer. You're an extremely patient person. Seriously though, what made you get back to this post? I'm very curious. :)
I was just looking back over my old posts and I noticed it. Thanks.
2

No, jQuery is not an integral part of CRM. There is an SDK example of using jQuery to consume the REST endpoint and it shows to include a jQuery web resource on the form.

http://msdn.microsoft.com/en-us/library/gg309549.aspx

Comments

0

Try changing

$.ajax({

to

jQuery.ajax({

2 Comments

Isn't that like changing var s = 3; to var t = 3; and hoping for a difference? You've got me unsure...
No. jQuery can be referenced as $ and jQuery. Both are the same object.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.