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
<?php | |
// Establish a new database connection | |
// Barebones edition | |
$db = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME, DB_USER, DB_PASS); | |
// Advanced edition | |
$db = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8;port=3306', DB_USER, DB_PASS); | |
?> |
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
<files config.php> | |
order allow, deny | |
deny from all | |
</files> |
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
// ---- | |
// libsass (v3.2.5) | |
// ---- | |
.a, .b, .c { | |
&:hover .RemoveImg { | |
display: inline; | |
} | |
} |
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
// Let's say we have a click handler and fires off a series of AJAX request | |
$selector.on('click', function() { | |
// Construct empty array | |
var deferreds = []; | |
// Loop using .each | |
$(this).find('div').each(function() { | |
var ajax = $.ajax({ | |
url: $(this).data('ajax-url'), | |
method: 'get' |
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
// Generic function to make an AJAX call | |
var fetchData = function(query, dataURL) { | |
// Return the $.ajax promise | |
return $.ajax({ | |
data: query, | |
dataType: 'json', | |
url: dataURL | |
}); | |
} |
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
// Declare "custom_photoset" function | |
function custom_photoset($attr) { | |
$args = shortcode_atts( | |
array( | |
'ids' => '', | |
'layout' => '' | |
), | |
$attr, | |
'photoset' | |
); |
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 a1 = $.ajax({ | |
url: '/path/to/file', | |
dataType: 'json' | |
}), | |
a2 = a1.then(function(data) { | |
// .then() returns a new promise | |
return $.ajax({ | |
url: '/path/to/another/file', | |
dataType: 'json', | |
data: data.sessionID |
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 a1 = $.ajax({...}), | |
a2 = $.ajax({...}); | |
$.when(a1, a2).done(function(r1, r2) { | |
// Each returned resolve has the following structure: | |
// [data, textStatus, jqXHR] | |
// e.g. To access returned data, access the array at index 0 | |
console.log(r1[0]); | |
console.log(r2[0]); | |
}); |
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({ | |
data: someData, | |
dataType: 'json', | |
url: '/path/to/script', | |
success: function(data, textStatus, jqXHR) { | |
// When AJAX call is successfuly | |
console.log('AJAX call successful.'); | |
console.log(data); | |
}, | |
error: function(jqXHR, textStatus, errorThrown) { |
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 ajaxCall = $.ajax({ | |
context: $(element), | |
data: someData, | |
dataType: 'json', | |
url: '/path/to/script' | |
}); | |
ajaxCall.done(function(data) { | |
console.log(data); | |
}); |