javascript - Why json_decode return NULL with hash symbol -


use $.post send array js php file:

    $.ajax({         url: window.location + "crawler/",         type: "post",         datatype: "json",         data: {             wartosc: zmienna         },         success: function (odp) {             tab = json.stringify(odp);             $.post(window.location + "crawler/return_data",                 {                     data: tab  //tab->array                 },                 function (data) {                     $('#wynik').html(data);                     $('.pobierz').show();                 }             )         }     }) 

before use json_decode() in php using var_dump($_post['data']); array looks this:

string(612) "[{"nazwa":"http://wp.pl/","adres ip":"212.77.98.9","kod odpowiedzi":301,"roboty":"-","tytul":"-","slowa kluczowe":"-","opis":"-"},{"nazwa":"http://www.wp.pl/","adres ip":"212.77.98.9","kod odpowiedzi":200,"roboty":"index,follow","tytul":"wirtualna polska - wszystko co ważne - www.wp.pl","slowa kluczowe":"wp.pl, wp, wirtualna polska, pogoda, wiadomości, newsy, informacje, sport, finanse, rozrywka, program, telewizja, #dziejesiewpolsce","opis":"nowoczesne medium, porządkuje świat dostarcza angażujące informacje, rozrywkę usługi w czasie rzeczywistym. przewodnik polaków w wirtualnym świecie."}]"  

and fine, when send array php script using (can't use ajax):

window.location.href = window.location + "crawler/save_to_csv?data=" + tab; 

and try var_dump($_get['data']); return:

string(422) "[{"nazwa":"http://wp.pl/","adres ip":"212.77.98.9","kod odpowiedzi":301,"roboty":"-","tytul":"-","slowa kluczowe":"-","opis":"-"},{"nazwa":"http://www.wp.pl/","adres ip":"212.77.98.9","kod odpowiedzi":200,"roboty":"index,follow","tytul":"wirtualna polska - wszystko co ważne - www.wp.pl","slowa kluczowe":"wp.pl, wp, wirtualna polska, pogoda, wiadomości, newsy, informacje, sport, finanse, rozrywka, program, telewizja, "  

string cut '#' symbol , if delete hash url string:

'#dziejesiewpolsce'

all works perfect, need hash symbol. how this?

thanks

you need encode value correctly usage in url.

in javascript:

... + "crawler/save_to_csv?data=" + encodeuricomponent(tab); 

Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -