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 966365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:08:45+00:00 2026-05-16T02:08:45+00:00

I made a script to post comments on a page. I have used PHP

  • 0

I made a script to post comments on a page. I have used PHP curl and it works but I need to use AJAX so the page doesn’t reload. When i use jQuery .post() the response says:

method not allowed use post or get.

This is my code:

include("userinfo.php");
if ($_POST['action'] === 'postcomment'){
    $imageid = $_POST['imageid'];
    $user = $_POST['username'];
    $text = $_POST['text'];
}

$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Expect:", "Api-Key: ".$apikey));
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $username.":".$password);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, "https://api.myphotodiary.com/users/".$user."/images /".$imageid."/comments.json");
curl_setopt($ch, CURLOPT_POSTFIELDS, array("text" => $text));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
$response = curl_exec($ch);
print_r($response);

And this is the jQuery:

$("form.imagecommentform").live("submit",function(e){
    $text = $(this).find(".text");
    $username = $(this).find(".username");
    $imageid = $(this).find(".imageid");
    $.post("inc/imagecomment.php",{
        immageid: $imageid.val(),
        username: $username.val(),
        text: $text.val()
        action: "postcomment"
    }, function(html) {
        $(this).find($(".msg")).empty();
        $(this).find($(".msg")).html(html);
    }, "json");
    return false;
});

Does anyone know what is wrong?

  • 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-05-16T02:08:45+00:00Added an answer on May 16, 2026 at 2:08 am

    I have fixed it by using $.ajax() instead of .post().

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

Sidebar

Related Questions

I have made a script, but it's not working as expected, and I need
Ok, i have made a contact form. i need a php script to email
I have made a simple plugin with a form but it won't post when
I made a PHP script for a form, but dont't know how to get
I have made this infinitely scrolling script, but I can't rebind the window scroll
I made a script before, that worked completely fine in PHP 5.2. But when
I made a little script that send a textarea content to PHP page with
i made one script from here but now i have problem with geting $_POST['file']
Hello I have made a PHP script for wordpress that insert new posts using
I have made a script that uses a program called Diascope, its a video

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.