We help IT Professionals succeed at work.
Get Started

Processing of  multiple variables echoed from php, as java scrip variables.

Ivan Golubar
Ivan Golubar asked
Last Modified: 2017-12-08
I attached illustration there is result of  code snippets below: string with user names (ivan4joni) and two users avatars .
I have two users : ivan4 and joni. As I have a while loop in php, I get names together as one string.

What would be the code for ajax to get a javascript variable as array [ ivan4 , joni]?
I don't need  users to be displayed as array on main page but as a array which will be then used in js functions.

  $.ajas x({
  url: '/wp-content/themes/net4/usersOnMainPageAjax.php',
  data:  {
      "actualproject": whichProjectToSave
   datatype: 'text',
    success: function(strdate){
  $('#usersWindowID > p').html(strdate);
     error: function(error, txtStatus) {

Open in new window

while($row = mysqli_fetch_array($query, MYSQLI_ASSOC)) {
echo $partners_username;
echo $partnersHTML;  

Open in new window

In general I need to learn how to get two variables with ajax from php.
Watch Question
This problem has been solved!
Unlock 2 Answers and 4 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE