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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:05:51+00:00 2026-05-31T03:05:51+00:00

I have problem with ajax and php.I have next code $(form).submit(function() { var poruka

  • 0

I have problem with ajax and php.I have next code

$("form").submit(function() {
 var poruka = $("#poruka").val();
  $.ajax({
        type: "GET",
        url: "/ajax/gather/send/"+ poruka + "/'.$id.'",
        success: function(){
         loaduj('.$id.');
         alert("Your message is "+poruka);
        },
        error: function(){
            alert("fail");
        }
    });
});

“poruka” is the message and it’s taken from form

<form action='javascript:;'>
<input type='text' name='poruka' id='poruka' placeholder='Poruka..' style='width:100%;'>
<input type='button' name='button' hidden>
</form>

And when i try to send to php it won’t insert that into database :

Php code :

$text = $_POST['text'];
$id = $_POST['id'];
if($text != ""){
  mysql_query("INSERT INTO messages (text,id2) VALUES ('$text','$id')") or     die(mysql_error());
}

And it can’t work..How can i fix it ? Thanks

  • 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-31T03:05:53+00:00Added an answer on May 31, 2026 at 3:05 am

    You use POST instead of GET. In your AJAX form you specify that you use GET, but in PHP you use $_POST superglobal.

    Change $_POST into $_GET in your PHP code and it should work 🙂

    Also if you do not specify method in your tag, the default is GET.

    From experience, in case if the data from the form is not written/updated in/to the database use

    echo mysql_error();
    

    after the MySQL query and also open the developer tools on your browser and inspect in the network panel. Developer tools can be opened using F12 and with CTRL+SHIFT+I if your F12 is not working due to the coffee spilled on it. Network panel shows the data being sent, the method used and every other detail of a network call. Also there you can see the response of your server side script which in this case would return a mysql error message because you echo’ed it out.

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

Sidebar

Related Questions

I have this jQuery event: $('#button-next').bind('click', function() { $.ajax({ type: GET, dataType: json, url:
I have this jQuery code: <script type=text/javascript > $(function() { $('#add_comment').bind('submit',function() //$(input[type=submit]).click(function() { var
I have set up an AJAX contact form on a client's website. The problem
The problem seems very strange. I have a AJAX helper function within a same
The problem is the following. We have lots of ajax call via $.ajax function.
I have some problem with my form. i want to use jquery ajax to
My problem is next: I have a form where inputs, labels and some other
I have problem with ajax loader image when I use the load() function, the
I have a problem in giving Ajax functionality to a hyperlink. I have files
I have strange problem with sharepoint and ajax functionality. We have an UpdatePanel placed

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.