|
|
|
немного не suggest
|
|||
|---|---|---|---|
|
#18+
Всем добра. появилась необходимость получить данные с lastfm suggest. Т.е. данные подсказки при наборе в поле. пробую так: Код: javascript 1. 2. 3. 4. 5. 6. 7. 8. 9. Syntax error at line 1 while loading: expected ';', got ':' {"responseHeader":{"status":0,"QTime" -----------------^ (Opera) Либо Uncaught SyntaxError: Unexpected token : (Chrome) Подскажите, что не так? или пните в нужном направлении) ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 09.02.2015, 21:49 |
|
||
|
немного не suggest
|
|||
|---|---|---|---|
|
#18+
Люди пишут такое: Код: javascript 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. })(jQuery); ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 10.02.2015, 11:08 |
|
||
|
немного не suggest
|
|||
|---|---|---|---|
|
#18+
тот же результат. Причем в обоих случаях запрос то осуществляется, ответ сервера - код ответа 200, application/json;charset=UTF-8 тело ответа: {"responseHeader":{"status":0,"QTime":0,"params":{"originalq":"queen","frompb":"true","q":"queen","userip":"xx.xx.xx.xx","wt":"json","rows":"10"}},"response":{"numFound":16449,"start":0,"docs":[{"id":"6-1270","reach":3591788,"weight":1.0,"resid":1270,"image":"45625545.jpg","artist":"Queen","restype":6},{"id":"6-1000569","reach":2255463,"weight":1.0,"resid":1000569,"image":"176855.jpg","artist":"Queens of the Stone Age","restype":6},{"id":"8-1831","reach":1524740,"resid":1831,"weight":0.5,"album":"Greatest Hits","image":"95148003.jpg","artist":"Queen","restype":8},{"id":"8-1416783","reach":1128703,"resid":1416783,"weight":0.5,"album":"Songs for the Deaf","image":"59975609.jpg","artist":"Queens of the Stone Age","restype":8},{"id":"6-16435665","reach":542347,"weight":1.0,"resid":16435665,"image":"181190.jpg","artist":"The Good, the Bad & the Queen","restype":6},{"id":"8-2024264","reach":896582,"resid":2024264,"weight":0.5,"album":"Greatest Hits II","image":"92633831.jpg","artist":"Queen","restype":8},{"id":"8-2027992","reach":862024,"resid":2027992,"weight":0.5,"album":"Lullabies to Paralyze","image":"47855851.jpg","artist":"Queens of the Stone Age","restype":8},{"id":"6-1004129","reach":394921,"weight":1.0,"resid":1004129,"image":"337253.jpg","artist":"Queensrÿche","restype":6},{"id":"6-1001052","reach":381881,"weight":1.0,"resid":1001052,"image":"37664651.jpg","artist":"Queen & David Bowie","restype":6},{"id":"9-12198","reach":1218301,"duration":355,"resid":12198,"weight":0.3,"track":"Bohemian Rhapsody","image":"45625545.jpg","artist":"Queen","restype":9}]}} в консоль ошибка выпадает Uncaught SyntaxError: Unexpected token : undefined может это не совсем JSON отдается? т.е. не верный формат? Хотя попробовал его PHP функцией json_decode почитать - нормально развернула Код: php 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 10.02.2015, 12:46 |
|
||
|
немного не suggest
|
|||
|---|---|---|---|
|
#18+
а если так передавать? {"responseHeader":[{"status":0,"Q....]} ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 10.02.2015, 12:51 |
|
||
|
немного не suggest
|
|||
|---|---|---|---|
|
#18+
заковыка в том, что запрос кросдоменный, и ответ формирую не я. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 10.02.2015, 12:58 |
|
||
|
немного не suggest
|
|||
|---|---|---|---|
|
#18+
kalamfurзаковыка в том, что запрос кросдоменный, и ответ формирую не я. http://stackoverflow.com/questions/8428739/i-cant-to-process-response-to-a-jsonp-request ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 10.02.2015, 13:06 |
|
||
|
немного не suggest
|
|||
|---|---|---|---|
|
#18+
Winnipuh, Код: javascript 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. в HEAD благополучно создается скрипт - <script src=" http://www.lastfm.ru/search/autocomplete?q=queen&callback= JSONPCallback_0"></script> ошибка та же. видимо при получении данных браузер сам проверяет, соответствуют ли данные запрошенному типу и выдает ошибку. Если на прямую скормить из консоли JSONPCallback_0('{"responseHeader":{"status":0,"QTime":0,"params":{"originalq":"queen","frompb":"true","q":"queen","userip":"xx.xx.xx.xx","wt":"json","rows":"10"}},"response":{"numFound":16449,"start":0,"docs":[{"id":"6-1270","reach":3591788,"weight":1.0,"resid":1270,"image":"45625545.jpg","artist":"Queen","restype":6},{"id":"6-1000569","reach":2255463,"weight":1.0,"resid":1000569,"image":"176855.jpg","artist":"Queens of the Stone Age","restype":6},{"id":"8-1831","reach":1524740,"resid":1831,"weight":0.5,"album":"Greatest Hits","image":"95148003.jpg","artist":"Queen","restype":8},{"id":"8-1416783","reach":1128703,"resid":1416783,"weight":0.5,"album":"Songs for the Deaf","image":"59975609.jpg","artist":"Queens of the Stone Age","restype":8},{"id":"6-16435665","reach":542347,"weight":1.0,"resid":16435665,"image":"181190.jpg","artist":"The Good, the Bad & the Queen","restype":6},{"id":"8-2024264","reach":896582,"resid":2024264,"weight":0.5,"album":"Greatest Hits II","image":"92633831.jpg","artist":"Queen","restype":8},{"id":"8-2027992","reach":862024,"resid":2027992,"weight":0.5,"album":"Lullabies to Paralyze","image":"47855851.jpg","artist":"Queens of the Stone Age","restype":8},{"id":"6-1004129","reach":394921,"weight":1.0,"resid":1004129,"image":"337253.jpg","artist":"Queensrÿche","restype":6},{"id":"6-1001052","reach":381881,"weight":1.0,"resid":1001052,"image":"37664651.jpg","artist":"Queen & David Bowie","restype":6},{"id":"9-12198","reach":1218301,"duration":355,"resid":12198,"weight":0.3,"track":"Bohemian Rhapsody","image":"45625545.jpg","artist":"Queen","restype":9}]}}') то отрабатывает нормально , возвращает объект (Object {responseHeader: Object, response: Object}) ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 10.02.2015, 13:55 |
|
||
|
немного не suggest
|
|||
|---|---|---|---|
|
#18+
немного жаль , но может кому пригодится результат)) проблема в том, что запрос возвращает JSON а не JSONP. и, соответственно, яваскрипту весь этот JSON не достается. придется тянуть через серверную обертку. P.S.: Winnipuh , большое спасибо!) ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 11.02.2015, 20:41 |
|
||
|
|

start [/forum/topic.php?fid=22&fpage=80&tid=1446280]: |
0ms |
get settings: |
7ms |
get forum list: |
15ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
44ms |
get topic data: |
11ms |
get forum data: |
2ms |
get page messages: |
54ms |
get tp. blocked users: |
1ms |
| others: | 207ms |
| total: | 347ms |

| 0 / 0 |
