2014-09-16 6 views
0

사용할 수 없습니다 :캐릭터 라인 데이터는 내가 자바 스크립트 객체를 stringifieng하고, JQuery와 포스트 방법을 통해 그것을 보낸다

reservation={}; 
count=0; 
$(".reservation").each(function() { 
    reservation[this.id]=jQuery(this).val(); 
    count++; 
    if (count==jQuery(".reservation").length) 
    { 
     reservationString=JSON.stringify(reservation); 
     $.post("helper.php", {reservation: reservationString}) .done(function(data) { 

은 "helper.php"파일 데이터를 얻을 수 있지만, quotatian 마크는 모두 탈출, 그래서 그것을 해독하려고 할 때, 나는 오류 코드와 더불어, JSON 오류가 발생 4. 여기에

는 helper.php 파일입니다

$reservation=$_REQUEST['reservation']; 
echo $reservation . "\n"; 
$reservation=json_decode(html_entity_decode($reservation)); 

나는 javas에 reservationString을 경고 시도 cript는 문자열이 이스케이프되지 않기 때문에 대부분 jQuery 포스트 메서드가 문자열을 이스케이프 처리합니다. 무슨 문제가 될 수 있니, 당신은 해결책을 제안 할 수 있습니까?

추가 정보를 정기적으로 : 이 내가 자바 스크립트 캐릭터 라인 객체를 경고 한 후 무엇을 얻을이 :

{\"test\":\"bubub\",\"Domain\":\"online\",\"Type\":\"banner\",\"s2id_CompanyId\":\"\",\"CompanyId\":\"-\",\"ContactPersonId\":\"0\"} 
+2

서버에서 마법 인용 부호가 활성화되어 있는지 확인하십시오 그것, 또는 당신이 위선적 인 경우,'$ reservation'에 stripslashes를 사용하십시오. – Steve

+0

stripslashes는 당장 작업을했지만, 나는 또한 magic quotes를 체크 아웃하고 있습니다. 감사! –

답변

0

이를 :

{"test":"bubub","Domain":"online","Type":"banner","s2id_CompanyId":"","CompanyId":"-","ContactPersonId":"0"} 

이것은 내가 PHP의 데이터에서 반향 후 무엇을 얻을 작동해야 함 :

$reservation=$_REQUEST['reservation']; 
echo $reservation . "\n"; 
$reservation=stripslashes(json_decode(html_entity_decode($reservation)); 
+0

아니요, 작동하지 않습니다. – Steve