How to Call Twitter API via an AJAX/PHP button using curl?



I’m trying to build a script that follows/unfollows people by pressing an AJAX button.
Let’s say I have 3 files:
tweeps.php - just a list of people with two buttons each - Follow/Unfollow

The latter two contain curl classes that call Twitter API and follow/unfollow specified people.

The trick is to remain on tweeps.php without having to navigate away to follow.php and unfollow.php so that people on the list simply disappear when unfollowed.

The problem is with curl, cross domain request can’t be done via AJAX.

Can you please suggest the best way of doing it?

Here’s something I tried:

var request = $.ajax({
  url: "",
  type: "GET",
  data: JSON.stringify({ "screen_name" : tweep }),
  dataType: "json",
  contentType: "application/json", success: function(data) {
    error: function(data) {
        alert("not ok");
       // debugger;
request.done(function( msg ) {
  document.getElementById(tweep).innerHTML='<img src="" />';
}); jqXHR, textStatus ) {
  alert( "Request failed: " + textStatus );