Created
January 21, 2011 00:33
-
-
Save quickredfox/789025 to your computer and use it in GitHub Desktop.
Un POST AJAX en jQuery
This file contains hidden or 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
/* Je prétends que ton POST est pas Cross-Domain.. */ | |
var tonCallback = function(textOrHTML){ | |
// si textOrHTML est du JSON | |
var json = JSON.parse(textOrHTML); | |
// sinon | |
var resultDocument = $(textOrHTML); | |
}; | |
// tu peut en plus de l'option "data" mettre des variables GET dans ton url... | |
var url = 'https://example.com/?getvarone=true&blahblah=false' | |
// setup pour un POST traditionel en Ajax jQuery | |
var postOptions = { | |
url: url, | |
type: 'POST', | |
dataType: 'json', | |
data: {foo:'bar',lol:'cat'}, // data POST ( foo=bar&lol=cat ) // | |
success: tonCallback | |
}; | |
// $.post te donne moin de controle. Et j'ai compris a la longue que pour le POST en AJAX ca prends du controle. | |
$.ajax(postOptions); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment