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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:59:33+00:00 2026-05-15T13:59:33+00:00

i have 4 strings in my application like this that i want to pass

  • 0

i have 4 strings in my application like this that i want to pass to my js file

$a1='[10,20,13,14]';
$a2='[17,15,14,16]';
$a3='[18,24,16,17]';
$a4='[15,54,18,27]';

echo $a1.",".$a2.",".$a3.",".$a4;

and my javascriptcode is

$.ajax({
           type: "POST",
           dataType: "json",
           url: "loaddata.php",
               success: function(data)
            {
           alert(data); //alert 15,54,18,27


          }
     });

i can get just $a4 string, and i can not get other string

how can i pass these 4 strings in php and set these 4 variables in javascript

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-15T13:59:34+00:00Added an answer on May 15, 2026 at 1:59 pm

    Encode them as JSON.

    On the PHP side:

    echo json_encode(array("a1" => $a1, "a2" => $a2, "a3" => $a3, "a4" => $a4));
    

    On the JavaScript side:

    $.ajax({
        type: "POST",
        dataType: "json",
        url: "loaddata.php",
        success: function(data) {
            var a1=data.a1;
            var a2=data.a2;
            var a3=data.a3;
            var a4=data.a4;
            // do something with a1, a2, a3 and a4
        }
    });
    

    And if you want a1, a2, a3, and a4 to be arrays of numbers instead of strings containing numbers, just JSON decode the strings on the PHP side before sending them over:

    echo json_encode(array(
        "a1" => json_decode($a1),
        "a2" => json_decode($a2),
        "a3" => json_decode($a3),
        "a4" => json_decode($a4)
    ));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a some of html strings that my application generates. Each html 'snippet'
I have created an Ajax enabled WCF web service that contains this simple method:
I have a function that returns a list like this:- List <Column <String1, String2>>
I created a route in ASP.net MVC application that looks like this: routes.MapRoute( ArticleRoute,
I want to pass arguments to a java application but like linux application style.
My application receives strings that represent objects. I have to parse the strings to
I have an application that contains a business entity called a 'Task'. This entity
I have an existing and working java web application. I want to make this
My application may have strings comprised of different alphabets / languages in a single
In my application,i have some .strings files.And on a button click,which is on my

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.