Created
October 19, 2015 21:43
-
-
Save brunohaveroth/76687962e1e1d461688a to your computer and use it in GitHub Desktop.
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
arquivo javascript | |
//code ajax of loading feed of facebook | |
var skipFb = 0; | |
$('.button-feed-fb').click(function(e) { | |
var idFeedFb = e.target.id; | |
if (idFeedFb === 'prev-feed-fb') { | |
if (skipFb > 0) { | |
skipFb--; | |
} | |
}else { | |
skipFb++; | |
} | |
$.ajax({ | |
url: ajaxurl, | |
type: 'POST', | |
data: { | |
'action' : 'get_feed_fb', | |
'skip' : skipFb | |
}, | |
success: function( response ){ | |
$('.facebook-content').html(response); | |
} | |
}); | |
}); | |
funcao do arquivo function.php | |
// Get the feed if facebook with paginate | |
function get_feed_fb() { | |
$skip = $_POST['skip']; | |
$urlRequest = "https://graph.facebook.com/tagon8/feed?access_token=989691144406052|xGG3uZqUmL9b1ycUlqbXj6MPlEw&limit=1&offset=$skip"; | |
$JSONcontent = file_get_contents($urlRequest); | |
$graphObject = json_decode($JSONcontent); | |
?> | |
<p class="bolder content-title"> | |
<?php | |
setlocale(LC_ALL, "pt_BR", "pt_BR.iso-8859-1", "pt_BR.utf-8", "portuguese"); | |
date_default_timezone_set('America/Sao_Paulo'); | |
echo strftime("%A, %d de %B de %Y", strtotime( reset($graphObject->data)->created_time )); | |
?> | |
</p> | |
<p class="content-text"> | |
<?php echo reset($graphObject->data)->message; ?> | |
</p> | |
<?php | |
wp_die(); | |
} | |
add_action('wp_ajax_nopriv_get_feed_fb', 'get_feed_fb'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tenta passar:
async: false
no objeto XHR do seu script.