This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://www.klauskomenda.com/code/javascript-programming-patterns/#module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var NewsWidget = (function () { | |
var s; // private alias to settings | |
function somePrivateFunction() { | |
alert("There are " + s.NumArticles + " articles"); | |
} | |
return { | |
settings: { | |
numArticles: 5, | |
articleList: $("#article-list"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function () { | |
$.ajaxSetup({ | |
headers: { 'Id': '776EF843' } | |
}); | |
$.ajax({ | |
type: 'GET', | |
url: 'http://webservice.net/test.svc/test', | |
dataType: 'json', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void Application_BeginRequest(object sender, EventArgs e) | |
{ | |
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*"); | |
if (HttpContext.Current.Request.HttpMethod == "OPTIONS") | |
{ | |
HttpContext.Current.Response.AddHeader("Cache-Control", "no-cache"); | |
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST"); | |
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept, TenantId"); // TenantId could be anything | |
HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "1728000"); | |
HttpContext.Current.Response.End(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function () { | |
$.ajax({ | |
type: 'GET', | |
url: 'http://localhost:63751/Service1.svc/json/4', | |
dataType: 'json', | |
crossDomain: true, | |
async: true, | |
success: function (data) { | |
jsonData = data; | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[WebService(Namespace = "Foo")] | |
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] | |
[System.ComponentModel.ToolboxItem(false)] | |
[System.Web.Script.Services.ScriptService] | |
public class GetData : System.Web.Services.WebService | |
{ | |
[WebMethod] | |
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)] | |
public string GetInfo() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.ajax( | |
{ | |
url: _spPageContextInfo.webServerRelativeUrl + "/_api/web/currentuser", | |
type: "GET", | |
headers: { | |
"accept": "application/json;odata=verbose", | |
}, | |
success: function (data) { | |
$("#message").text('Hello ' + data.d.Title); | |
}, |