How to post a tweet using Codebird PHP from pop-up window How to post a tweet using Codebird PHP from pop-up window jquery jquery

How to post a tweet using Codebird PHP from pop-up window


In the button click, you need another function that open the popup along with a tweet button.

Add the click event listener as postTweet to the new tweet button.

I created a sample snippet. Check it below.

To show the real time preview, you need to add the keyup event listener to the textarea which should copy it's value and add it as the innerHTML of the preview pane.

function openTweet(){    document.getElementsByClassName("preview")[0].style.display="";    document.getElementById("tweetPr").innerHTML = document.getElementById("tweet").value;    document.getElementById("tweet").addEventListener("keyup",      function(){          document.getElementById("tweetPr").innerHTML = document.getElementById("tweet").value;      });      document.getElementsByClassName("download-share")[0].style.display="none";}function postTweet() {  $.ajax({    type: "POST",    url: 'tweet.php',    data:{action:'call_this'},    success:function(html) {      alert('Success!');    }  });}
<div style="display:none;" class="preview"><textarea id="tweet"> </textarea><div id="tweetPr"></div><button onclick="postTweet();">Tweet</button></div><button class="download-share" onclick="openTweet()">Download and Share</button>