Skip to content

Instantly share code, notes, and snippets.

@samuelloza
Last active July 30, 2017 21:50
Show Gist options
  • Save samuelloza/05c510db014f691f7216348e82151f0c to your computer and use it in GitHub Desktop.
Save samuelloza/05c510db014f691f7216348e82151f0c to your computer and use it in GitHub Desktop.
JavaScript HElps
Interesting Jquery
____________________________________________________________________________________
//Añadir elementos a un select
$('#mySelect')
.append($("<option></option>")
.attr("value",key)
.text(value));
_____________________________________________________________________________________
selection tag select for select value
example : $('#species select option[value="' + + '"]').prop('selected',true);
$('#words').val("{{$card_word->id_wd}}").change();
____________________________________________________________________________________
AJAX jquery charge call ajax example
http://stackoverflow.com/questions/3709597/wait-until-all-jquery-ajax-requests-are-done
$.when(ajax1(), ajax2(), ajax3(), ajax4()).done(function(a1, a2, a3, a4){
// the code here will be executed when all four ajax requests resolve.
// a1, a2, a3 and a4 are lists of length 3 containing the response text,
// status, and jqXHR object for each of the four ajax calls respectively.
});
function ajax1() {
// NOTE: This function must return the value
// from calling the $.ajax() method.
return $.ajax({
url: "someUrl",
dataType: "json",
data: yourJsonData,
...
});
}
_____________________________________________________________________________________
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment