On the server with the help of Ajax, I get a json line like this:

[ { "original_name":"Penguins.jpg", "serverurl":"upload/images/51528167ef67370933c5b95eed605d60.jpg" }, { "original_name":"Tulips.jpg", "serverurl":"upload/images/216f59417d2a304a1e5604ec070007fa.jpg" } ] _csrf=Y1FxYVNpUnckF‌​R45PSViEAtnABkZUGUmC‌​SIGCBRROkQUOUAuAFEaI‌​g==" – 

How to get rid of the csrf token and parse a string into an array?

  • Once this needs to be done on the server side, show the required code section - ilyaplot

1 answer 1

Crop line:

 var str = '[ { "original_name":"Penguins.jpg", "serverurl":"upload/images/51528167ef67370933c5b95eed605d60.jpg" }, { "original_name":"Tulips.jpg", "serverurl":"upload/images/216f59417d2a304a1e5604ec070007fa.jpg" } ]_csrf=Y1FxYVNpUnckF‌​R45PSViEAtnABkZUGUmC‌​SIGCBRROkQUOUAuAFEaI‌​g=='; str = str.substring(0, str.indexOf('_csrf')); 

Sparse a string into an object using jQuery:

 var json = $.parseJSON(str); 
  • I need to do this on the server side using php - Sabir Gojayev