Botões de alternância de dados HTML5 [FORM]

HTML <div data-toggle=”buttons-radio”><button type=”button” class=”btn” id=”yesBtn” data-info='{“post”:”1″}’>Yes</button><button type=”button” class=”btn” id=”noBtn” data-info='{“post”:”0″}’>No</button></div> CAMPO OCULTO <input type=”hidden” id=”post_to_fb” name=”post_to_fb” value=””> jQuery $(‘#yesBtn’).click(function(e) {e.preventDefault();thisdata = $(‘#yesBtn’).data(‘info’).post;//console.log(thisdata);$(“#post_to_fb”).val(thisdata);});$(‘#noBtn’).click(function(e) {e.preventDefault();thisdata = $(‘#noBtn’).data(‘info’).post;//console.log(thisdata);$(“#post_to_fb”).val(thisdata); });

Continuar lendo

Post JSON Body to API com Basic HTTP Authentication usando Objective C e AFNetworking 2.0

Certifique-se de verificar as diferentes opções NSURLCredentialPersistence – e nunca escreva uma senha no código. NSString *URLString = @”http://example.com/path”;NSDictionary *parameters = @{ };NSURLRequest *request = [[AFJSONRequestSerializer serializer] requestWithMethod:@”POST” URLString:URLString parameters:parameters …

Continuar lendo

Post JSON Body to API com Basic HTTP Authentication usando Objective C e AFNetworking 1.0

Eu uso SFHFKeychainUtils como um pacote para acessar e armazenar dados seguros – neste caso, a senha do usuário. NSString *username = userProvidedUsername;NSString *password = [SFHFKeychainUtils getPasswordForUsername:username andServiceName:@”com.mydomain.myapp.credentials” error:nil];NSDictionary *jsonRequestDictionary …

Continuar lendo