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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:13:57+00:00 2026-05-26T01:13:57+00:00

So I half got jQuery’s ajax ( $.post ) to work. But, for some

  • 0

So I half got jQuery’s ajax ($.post) to work. But, for some reason, I haven’t been successful with finding the right online article to explain to me how PHP retrieves the ajax data that is sent. I’ve found some stuff on json_decode, but upon me doing that to basically decode it, it wont work (and yes, I am using json for the $.post command).

Here is my javascript code

$.post("notificationNum.php", {"user":"1"},
                function(data){
                        $(".example-number").html(data.amount);
                }, "json");

Here is my PHP code

<?php
session_start();
//link to db info here

$user_id_got = json_decode($_REQUEST['user']);

$checknoti = mysql_query("SELECT * FROM notifications WHERE notification_users = '".$user_id_got."' AND notification_viewed= '0'");

  echo json_encode(array("amount"=>mysql_num_rows($checknoti)));
?>  

Mind you all, I’ve also tried using the $_POST command instead of the $_REQUEST. Any ideas how to send data to the PHP file so I can use it?

  • 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-26T01:13:58+00:00Added an answer on May 26, 2026 at 1:13 am

    “json” in your jQuery call is how your php should write its output, not how jQuery sends it. Use normal $_REQUEST in your php:

     $user_id_got = $_REQUEST['user'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got this half working but, when I try and create an if
Got some doubts with bottom half.Here, I consider tasklets only. Also , I consider
I got assigned to work on some performance and random crashing issues of a
Seriously, I've trawled MSDN and only got half answers - what do the columns
Half a year ago, I tried Visual Studio 2010 Beta 1, but it was
I half-answered a question about finding clusters of mass in a bitmap . I
About a half dozen times now, I’ve been doing a regular chore in Visual
I'm a little new to drupal but have been using things like devel module
I've spent half day trying to figure out this and finally I got working
I need some help in jQuery. What I'm trying to do is to create

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.