Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8895235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:43:28+00:00 2026-06-14T23:43:28+00:00

i want to execute a php script when i click on a button in

  • 0

i want to execute a php script when i click on a button in html generated by javascript,i was trying with jquery ajax and i did this but nothing happens…any help pls?the php script is working so its not that,i guess i am missing something in this ajax call…

Ajax call

$(".formBtn").click(function(){

    $.ajax({
        url: "script to call",
        type: "post",

        // callback handler that will be called on success
        success: function(response, textStatus, jqXHR){
            // log a message to the console
            console.log("Hooray, it worked!");
            alert("Working!");
        },
        // callback handler that will be called on error
        error: function(jqXHR, textStatus, errorThrown){
            // log the error to the console
            console.log(
                "The following error occured: "+
                textStatus, errorThrown
            );
        },
        // callback handler that will be called on completion
        // which means, either on success or error
        complete: function(){
            // enable the inputs
            $inputs.removeAttr("disabled");
        }
    });

});

PHP srcipt

$api_key = 'apikey';
    $project_id = 'projectid';
    $phone_id = 'phoneid';    
    $to_number = 'number';
    $content = 'content';


    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, 
        "urlblblbll");
    curl_setopt($curl, CURLOPT_USERPWD, "{$api_key}:");  
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query(array(
        'content' => $content,
        'phone_id' => $phone_id,
        'to_number' => $to_number,

    )));        



    $json = curl_exec($curl);    
    if ($err = curl_error($curl)) { echo "$err\n"; }    
    curl_close($curl);    

    $res = json_decode($json, true);        

    var_dump($res); // do something with $res
    } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:43:29+00:00Added an answer on June 14, 2026 at 11:43 pm
     $result = curl_exec($curl);   
     if($result)
     {
        $json['result'] = 'true';
     } 
     else
     {
        $json['result'] = 'false';
     }
    if ($err = curl_error($curl)) { echo "$err\n"; }    
    curl_close($curl);    
    
    $res = json_decode($json, true);  
    

    Can you try this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have asp.net generated html code. I want execute jQuery click function when user
I've got a css/html menu, now I want to execute this PHP-Script every time
I want to run a shell script in php, but this shell script takes
Let's say I want to execute a PHP script. Which way is better? This:
I want to load .php files via ajax which execute ExtJS script as they
I want to redirect using .htaccess abc.com/test.php to abc.com/test . but it will execute/display
I'm new to Javascript. The code for a jQuery-ajax-php-cooperation does strange things. It works
im want to execute a php script every 10 min in order to retrive
i want to execute a php script every day. i have a bash script
I have a php script I want to execute regularly using a crontab. I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.