Have a closer look at the returned JSON.
I've re-formatted it here in an effort to make its structure more clear. (copy the contents of this code-block and paste it into an editor that doesn't wrap long lines to make it clear. CP's line-wrapping muddies the waters a bit)
[
{
"trends":
[
{ "name": "#MukhangPeraAngPilipinas", "query": "%23MukhangPeraAngPilipinas", "url": "http:\/\/twitter.com\/search?q=%23MukhangPeraAngPilipinas", "promoted_content": null },
{ "name": "#FelizDiaDelPadre", "query": "%23FelizDiaDelPadre", "url": "http:\/\/twitter.com\/search?q=%23FelizDiaDelPadre", "promoted_content": null },
{ "name": "#BeforeTwitterI", "query": "%23BeforeTwitterI", "url": "http:\/\/twitter.com\/search?q=%23BeforeTwitterI", "promoted_content": null },
{ "name": "#BDMELODI_164", "query": "%23BDMELODI_164", "url": "http:\/\/twitter.com\/search?q=%23BDMELODI_164", "promoted_content": null },
{ "name": "#\u00d6nSe\u00e7imeGirenTekLider", "query": "%23%C3%96nSe%C3%A7imeGirenTekLider", "url": "http:\/\/twitter.com\/search?q=%23%C3%96nSe%C3%A7imeGirenTekLider", "promoted_content": null },
{ "name": "T\u00fanez", "query": "T%C3%BAnez", "url": "http:\/\/twitter.com\/search?q=T%C3%BAnez", "promoted_content": null },
{ "name": "Nasir Hossain", "query": "%22Nasir+Hossain%22", "url": "http:\/\/twitter.com\/search?q=%22Nasir+Hossain%22", "promoted_content": null },
{ "name": "Dwight Walker", "query": "%22Dwight+Walker%22", "url": "http:\/\/twitter.com\/search?q=%22Dwight+Walker%22", "promoted_content": null },
{ "name": "\u063a\u064a\u0631 \u0627\u0644\u0645\u0634\u0631\u0648\u0639", "query": "%22%D8%BA%D9%8A%D8%B1+%D8%A7%D9%84%D9%85%D8%B4%D8%B1%D9%88%D8%B9%22", "url": "http:\/\/twitter.com\/search?q=%22%D8%BA%D9%8A%D8%B1+%D8%A7%D9%84%D9%85%D8%B4%D8%B1%D9%88%D8%B9%22", "promoted_content": null },
{ "name": "\u0635\u0648\u062a \u0627\u0644\u0645\u0637\u0631", "query": "%22%D8%B5%D9%88%D8%AA+%D8%A7%D9%84%D9%85%D8%B7%D8%B1%22", "url": "http:\/\/twitter.com\/search?q=%22%D8%B5%D9%88%D8%AA+%D8%A7%D9%84%D9%85%D8%B7%D8%B1%22", "promoted_content": null }
],
"as_of": "2015-03-19T11:19:49Z",
"created_at": "2015-03-19T11:15:05Z",
"locations":
[
{
"name": "Worldwide",
"woeid": 1
}
]
}
]
The first few characters are: "[ {", which indicates an array. However, you access it as though the first character is "{".
I imagine the solution is as simple as:
var rawData = response;
var jsonObj = JSON.parse(response);
var name = jsonObj[0].trends[0].name;
Not sure if you've turned the returned string back into an object or not. You need to do that as shown above. The snippet I've posted assumes that
response
contains the text of the JSON. It should then set
name
to hold the text "#MukhangPeraAngPilipinas", which is the name held by the first trend in the array of them.