Posts

Showing posts from December 27, 2015

REST / AJAX calls from within a Jaggery script

Image
<% var mySecureToken = FnMakeRequestCall("https://10.299.99.99:8245/token","POST","Basic RlN4S2RrZEpNN3VaYWhHN0NFcEtlaTZEa3RzYTpXbmUxd29seHp2UTNSQ2RZbXhUUTJ2WkJTd0Fh","application/x-www-form-urlencoded; charset=UTF-8",""application/json; charset=utf-8","grant_type=password&username=pcsadmin&password=pcsadmin");  print(mySecureToken); function FnMakeRequestCall(URL, METHOD, BASICAUTH, CONTENTTYPE, ACCEPTTYPE, INPUTDATA){ if(BASICAUTH){ //var VarBasicAuthCode = util.FnCreateBasicAuthentication(VARSKYSPARKUSERNAME,VARSKYSPARKPASSWORD); var VarBasicAuthCode = session.get('authToken'); } xhr = new XMLHttpRequest(); xhr.open(METHOD, URL); if(BASICAUTH){ xhr.setRequestHeader("Authorization" , VarBasicAuthCode); } xhr.setRequestHeader("Content-Type", CONTENTTYPE); xhr.setRequestHeader("Accept", ACCEPTTYPE); xhr.send(INPUTDATA); var VarRes...

Should You Use the ‘var $this = $(this);’ Syntax in jQuery?

A common jQuery coding practice  var $this = $(this);  There are a few benefits:   $(this) is only evaluated once (minor efficiency)  You can use a more descriptive name for $(this). I’m using var $MyCurrentBook = $(this);  By preceding the variable name with the $ sign, you’re reminding yourself that it’s a jQuery variable, not just a plain old JavaScript variable.