Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
How to get a Javascript array from php and save it in javascript array, in javascript?

Javascript Ajax call gets data from a table through PHP. It returns data as a Javascript array.

  • When i do the console.log(this.responseText) I get the following
[['ID','StudentName','Age'],['1','Student1','25'], ['2','Student2','24'], ['3','Student3','22'], ] 
  • When i type at console this.responsetext, i get the following
"[['ID','StudentName','Age'],['1','Student1','25'], ['2','Student2','24'], ['3','Student3','22'], ]"  ( quotes added )
  • When i save this to a variable as following ,
myarray=this.responsetext

...it gets saved as string.

  • When I save this to the variable as following (without quotes)
myarray=[['ID','StudentName','Age'],['1','Student1','25'], ['2','Student2','24'], ['3','Student3','22'], ] 

...it is properly saved as an array.

I tried to remove the quotes(") by replace method, but it doesnt have any effect.

How to get a Javascript array from PHP and save it in javascript array, in javascript?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!