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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:31:06+00:00 2026-06-01T17:31:06+00:00

In my page I need to send an array in javascript to Phpscript. My

  • 0

In my page I need to send an array in javascript to Phpscript. My code doesn’t return a value and does not give an error. How can I do that?

arr[0]='one';
arr[1]='two';
arr[2]='three';
arr[3]='four';

$.post(
       'sort2.php', 
       {data:arr}, 
       function(result) {
                         alert(result[0]);                  
       },
       'json' 
);

In sort2.php

$data=$_GET["arr"];
echo json_encode($data);
  • 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-01T17:31:08+00:00Added an answer on June 1, 2026 at 5:31 pm
    1. You got $_GET and $_POST mixed up in the PHP script.
    2. It should be $_POST['data'], not $_POST['arr'] (the arr array is passed under the key name data in your JavaScript code: {data:arr}.)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to send a byte array from javascript into a c# page method.
I am working on an HTML page where i need to send confirmation by
I need to send a post request when the user leaves the page in
Hallo, I need to send a request to a page (POST) and then, I
I need to construct the URL of a page in a String, to send
In my page I need to give my current variable as parameter to the
I want to send a variable from my php page to my jquery code.
I'm trying to send an array to another page. What I tryed before was:
If a user refreshes a page I need to send the data using php
I am trying to build an estimates page and need to send via email

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.