title: Using Dynamic Scripts to load JSON Data - Cross Domain - CORS not available
body: <p>I have a ServiceNow instance running and I'm trying to pull all the users using the JSON Library.  I can easily see the JSON list of users if I type in the URL that dumps this data, I'm trying to create a webpage that will take this JSON list and make a list of users out of it.  I keep encounter cross domain issues, CORS is not available for me to use therefore I'm trying to dynamically load scripts according to the user's information.  This is the code that I'm trying to get working.</p>
  
  <pre><code>        function test() {
          var username = document.getElementById("username").value;
          var password = document.getElementById("password").value;
          var domain = document.getElementById("domain").value;
          var targeturl = "https://" + username + ":" + password + "@"
              + domain + "/sys_user_list.do?JSON&amp;sysparm_action=getRecords";
          $.getScript(targeturl + "&amp;callback=dumpData")
          function dumpData(data) {
              alert(data);
          }
      }
  </code></pre>
  
  <p>At this point the script seems to load properly, but it causes a syntax error.</p>
  
  <p>Uncaught SyntaxError: Unexpected token : </p>
  
  <p>How am I supposed to make the getScript call so I can get my JSON Data?  Is this even a valid method, I stumbled across when trying to figure this issue out and it seems like its my only option.  I've tried YQL but that doesn't work.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I have redone the code to make use of the $.ajax, here is the code</p>
  
  <pre><code>            $.ajax({
              url: 'https://' + username + ':' + password + "@" + domain + '/sys_user_list.do?JSON&amp;sysparm_action=getRecords&amp;callback=test',
              type: "GET",  
              success: function (data) {
                  alert("hello");
              },
              crossDomain: true,
              dataType: "jsonp",
              jsonpCallback: 'test'
          });
          function test(data) {
              alert("It worked!");
          }
  </code></pre>
  
  <p>I've scoured all the posts relating to this an still can't figure this one out.  Anybody have any advice on how to remedy this situation?  It still is given the invalid syntax error.  Is it just not possible to get this JSON data?</p>
  
  <p>I also have tried YQL to obtain the data but that encounters security issues as well.</p>
  
  <p>Thanks,</p>
  
  <p>Chris</p>