Skip to content

Instantly share code, notes, and snippets.

View brian-lim-42's full-sized avatar
πŸ‘¨β€πŸ’»
Making the next great thing...

Brian Lim brian-lim-42

πŸ‘¨β€πŸ’»
Making the next great thing...
View GitHub Profile
$.ajax({
type: 'POST',
data: xmlString,
contentType: 'application/xml',
dataType: 'json',
success: function (data) {
alert('SOAP Request:' + data);
}
});
public class TestModel()
{
public string TestString {get; set;}
public int TestInt {get; set;}
public bool TestBool {get; set;}
}
public ActionResult TestController(TestModel model) {
// TODO logic here...
}
var obj = {};
obj.TestString = "Test";
obj.TestInt = 1;
obj.TestBool = true;
$.ajax({
type: 'POST',
url: '@Url.Action("Test", "Test")', // replace this with the name of the controller and model
data: JSON.stringify(obj),
dataType: "html",
success: function (html) {
@brian-lim-42
brian-lim-42 / gist:e490a926e159b2ae6b84
Created August 8, 2015 21:31
jQuery UI Open Dialog and Create a Close Button
var modalDialog = $('#dialogDiv').dialog({
autoOpen: false,
open: function () {
// Destroy Close Button (for subsequent opens)
$('#dialog-div-close').remove();
// Create the Close Button (this can be a link, an image etc.)
var link = '<a id="dialog-div-close" href="#" style="float:right;text-decoration:none;">Close</a>';
// Create Close Button
$(this).parent().find(".ui-dialog-titlebar").append(link);
function createXML(json, rootName) {
var doc = document.implementation.createDocument(null, null, null);
var rootNode = doc.createElement(rootName);
var xml = createXMLRecursive(doc, rootNode, json);
return doc.appendChild(xml);
}
function createXMLRecursive(doc, node, json) {
for (var literal in json) {
// for string literals
function objToJson (obj, rootName) {
var root = {};
root[rootName] = {};
objToJsonRecursive(root[rootName], obj);
return root;
}
function objToJsonRecursive(root, obj) {
for (var key in obj) {
@brian-lim-42
brian-lim-42 / type.js
Created May 6, 2017 14:40
JavaScript Type Handling
class Type {
static isBoolean(val) {
return typeof(val) === 'boolean';
}
static isNull(val) {
return val === null;
}
@brian-lim-42
brian-lim-42 / template.js
Created May 10, 2017 18:41
Mustache Template
class {{clazz}} {
constructor(
{{#params}}
{{> param}}
{{/params}}
) {
{{#attribs}}
{{> attrib}}
{{/attribs}}
var app = app || {};
var app.engine = app.engine || {};
var app.engine.renderer = app.engine.renderer || {};