ajax - Retrieve JSON information? Jquery -
ok, might seem dumb question, please keep in mind json new me (i've heard expression before. know nothing it).
i have callback function notify authors on site email, when new comments added disqus thread.
<script type="text/javascript"> function disqus_config() { this.callbacks.onnewcomment = [function(comment) { var authname = document.getelementbyid('authname').value; var authmail = document.getelementbyid('authmail').value; var link = document.getelementbyid('link').value; var disqusapikey = 'my_api_key'; var disquscall = 'https://disqus.com/api/3.0/posts/details.json?post=' + comment.id + '&api_key=' + disqusapikey; $.ajax({ type: 'post', url: 'url_of_mail.php', data: {'authname': authname, 'authmail': authmail, 'link': link, 'disquscall': disquscall}, cache: false, }); }]; } </script>
everything works charm. except... outside scope of understanding (and i've searched around. seeing don't know json, don't know for) how extract information 'disquscall' variable? sits now, link (that contains 2 things i'm interested in, name , message). include these in mail message.
i'm sure simple "decoding" json information, don't know how. , posts i've found on subject have confused me more haha
you need provide success callback, in order use returned json data.
$.ajax({ type: 'post', url: 'url_of_mail.php', data: { 'authname': authname, 'authmail': authmail, 'link': link, 'disquscall': disquscall }, cache: false, success: function (data) { if(data.length>0) { //read json data } } });
Comments
Post a Comment