获取php数组后将其转换为javascript

I am fetching results from php via ajax. My result in the serverside looks like this.

Array
(
    [0] => IBM Mainframe
    [1] => Intel
    [2] => MIPS
    [3] => MMIX
    [4] => Computer Science (AP/College Intro)
    [5] => Computer Science (College Advanced)
    [6] => Android Programming
)

I am currently printing it out in console.

Serverside : print_r($result);

Clientside :

success: function(r){
                   console.log(r)
               }

I want to fetch the result and within the success convert it into something like this :

var name = [
        "IBM Mainframe",
        "Intel",
        "MIPS",
        "MMIX",
        "Computer Science (AP/College Intro)",
        "Computer Science (College Advanced)",
        "Android Programming"
]

So I can use that variable later

success : function(r){

..............

var name = ....

}
查看全部
duanjucong3124
duanjucong3124
2015/06/23 10:03
  • php
  • arrays
  • ajax
  • javascript
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复