Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Getting StartedGetting StartedjQuery cross-domain call using JSONPjQuery cross-domain call using JSONP
Previous
 
Next
New Post
2/5/2012 2:21 AM
 

Hi,

I'm trying to retrieve the Skype online status for a user and use that in decision making within a DNN module.
I have created a TEST HTML page using the same version of jQuery that is installed with DNN 6.1.3 and have it working as expected.
My problem though is implementing this within my DNN module - I get jQuery errors - parseerror.

Is there anything I need to do in order to enable DNN to make cross-domain queries with jQuery.getJSON?
The code may not be the neatest or best, but at least it works in the test page.

Any help would be greatly appreciated.

This is my test HTML page that works correctly:

<html>
 <head>
  <title>Test Page</title>

  <script type="text/javascript" src="jquery/jquery.js" ></script>

  <script type="text/javascript">

   // check the current status of the user from Skype
   function checkSkypeStatus()
   {
    var skypeName = document.getElementById("txtSkypeName").value;
    var skypeUrl = "http://mystatus.skype.com/" + skypeName + ".xml";

    // use YQL with JSON to perform cross-domain request and return XML data
    $.getJSON("http://query.yahooapis.com/v1/public/..."
       + encodeURIComponent(skypeUrl) + "%22&format=xml'&callback=?",
       function(data){
        // data.results);
        if (data.results != null)
        {
         // data.results);
         var skypeName = document.getElementById("txtSkypeName").value;

         var xmlOrg = data.results.toString();    // get the original XML response
         var xmlNew = xmlOrg.replace(/xml:/g, "");  // strip xml: namespace from presense nodes

         var xml = $.parseXML(xmlNew);        // parse the XML into an XmlDocument
         var $xmlDoc = $( xml );
         // from XML: ' + $xmlDoc.find('presence[lang="NUM"]').text());
         //var status = $xmlDoc.find('presence:first').text();
         var status = $xmlDoc.find('presence[lang="NUM"]').text();  // read the status code from the XML

        //¦0 – unknown
        //¦1 – offline
        //¦2 – online
        //¦3 – away
        //¦4 – not available
        //¦5 – do not disturb
        //¦6 – invisible
        //¦7 – skype me

         if (status == "1")
         {
          //document.getElementById("status").innerText = skypeName + " is currently offline";
          $("#status").text( skypeName + " is currently offline");
          $("#SkypeStatus").replaceWith("<img id='SkypeStatus' src='' alt='skypeName + is currently offline' />");
         }
         else if(status == "2")
         {
          $("#status").text( skypeName + " is currently online");
         }
        }
        else
         $("#status").text( skypeName + " status is unknown");

       });  // end of callback function to process the response from skype
   } // function checkSkypeStatus()

  </script>

 </head>

 <body>
  <h1>This is my test page</h1>

  <input type="text" id="txtSkypeName" name="txtSkypeName" value="alon.hirsch" /><br />
  <button value="Click me!" onclick="checkSkypeStatus()">Click ME!</button>
  <p id="status" >Checking online status ...</p>
  <div id="SkypeStatus">
  </div>

 </body>

</html>

Thanx,
Alon

 
New Post
2/5/2012 7:22 AM
 
It appears that I had an extra space in the URL being called and that's why it gave the parse error.
I made sure to remove any spaces from the url (part of the SkypeName value) and it is now working.

Thanx,
Alon
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Getting StartedGetting StartedjQuery cross-domain call using JSONPjQuery cross-domain call using JSONP


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out