0

I'm trying to run a script which pulls some information from an API. It seems to work in chrome and it also works in IE if I load the javascript on its own in a seperate page, but in my sharepoint site the javascript file loads in IE and does nothing. It works fine if I load the sharepoint site in Chrome and firefox.

Can anyone see something wrong with the javascript? The debugger doesn't show any errors

function getWallNew() {
        var data = {
          client_id: "****",
          client_secret: "***",
          grant_type: "client_credentials",
          scope: "recognition_events"
        };
        var prom = jQuery.ajax({
          url: "https://auth.appreciatehub.com/token",
          method: "POST",
          data: data
        });
        prom.then(function(res) {
            var tokenRes = res;
          console.log("in function")
          var wallProm = jQuery.ajax({
            url: "https://vision.appreciatehub.com/api/wall/feeds/",
            method: "GET",
            beforeSend: function(req) {
              req.setRequestHeader('Authorization', "Bearer " + tokenRes.access_token);
              req.setRequestHeader('accept', "application/hyper+json");

            }
          });
          wallProm.then(function(res) {

            var eventProm = jQuery.ajax({
              url: res.collection[0].href,
              method: "GET",
              beforeSend: function(req) {
                req.setRequestHeader('Authorization', "Bearer " + tokenRes.access_token);
                req.setRequestHeader('accept', "application/hyper+json");

              }
            });
            eventProm.then(function(res) {
                            var message = res.message;
              var award = res.award[0];

              var recipientProm = jQuery.ajax({
              url: res.recipients[0].href,
              method: "GET",
              beforeSend: function(req) {
                req.setRequestHeader('Authorization', "Bearer " + tokenRes.access_token);
                req.setRequestHeader('accept', "application/hyper+json");

              }
            });
            recipientProm.then(function(res){

            if (message.length > 300) {
              message = message.substring(0, 300);
              document.getElementById("readMoreLink").style.visibility = "";
            }

            document.getElementById("Name").innerHTML = res.name;
            document.getElementById("Department").innerHTML = res.department.title;
            document.getElementById("Message").innerHTML = message;
            document.getElementById("Image").src = res.avatar.thumb.src;


            });



            });

          });
        });
      }
      jQuery(document).ready(getWallNew());
  • What's the current IE & SharePoint version – Mohamed El-Qassas MVP Feb 19 '18 at 12:06
  • Please open console from developer tool and see what is error. Please check is .innerHTML supported in you current IE version? – Bharat Khunti Feb 19 '18 at 12:06
  • @MohamedEl-QassasMVP Im using sharepoint 2010 and IE11, innerhtml should be working fine there is no error in the developer tool – minglee Feb 19 '18 at 12:52
1

Careful using Console.log in IE. In IE, the log is only available if the dev tools (f12) are running. A quick solution is to check for the console object, and either not log if it's not available, or to create an object so that the call doesn't fail. Example code and a longer explanation is here.

  • Doesn't seem to be an issue with the console.log, took it out and still nothing happening. I also ran the code in a fiddle on IE which seems to work fine, im thinking its a sharepoint problem maybe? – minglee Feb 19 '18 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.