2010-07-27 60 views
0

我需要發佈60個輸入。我建立了json字符串並將其存儲在一個變量中。但不幸的是下面的代碼不工作:

$.post("process_form.php", my_var); 

my_var包含格式的JSON字符串:

{ starta:'1', currenta:'5', finisha:'2', startb:'1', currentb:'5', finishb:'2', startc:'1', currentc:'5', finishc:'2', startd:'1', currentd:'5', finishd:'2', starte:'1', currente:'5', finishe:'2', startf:'1', currentf:'5', finishf:'2', startg:'1', currentg:'5', finishg:'2', starth:'1', currenth:'5', finishh:'2', starti:'1', currenti:'5', finishi:'2', startj:'1', currentj:'5', finishj:'2', startk:'1', currentk:'5', finishk:'2', startl:'1', currentl:'5', finishl:'2', startm:'1', currentm:'5', finishm:'2', startn:'1', currentn:'5', finishn:'2', starto:'1', currento:'5', finisho:'2', startp:'1', currentp:'5', finishp:'2', startq:'1', currentq:'5', finishq:'2', startr:'1', currentr:'5', finishr:'2', starts:'1', currents:'5', finishs:'2', startt:'1', currentt:'5', finisht:'2' } 

任何想法,爲什麼這不會工作?或者怎麼做呢?

+0

你是什麼意思與*不起作用*?你在控制檯上遇到任何錯誤嗎?數據是否被髮送?用Firebug檢查。實際上,與JSON沒有任何關係,它不是JSON字符串,而是對象字面值。 – 2010-07-27 18:18:38

回答

0

嘗試在鍵和值周圍使用雙引號。

使用此測試的JSON是有效的: http://json.parser.online.fr/

或只使用jQuery的序列化方法

+0

數據已發送,但是其作爲單個字符串發送。我的原始字符串未在您鏈接的json工具中驗證。我在兩個地方添加了雙引號,並進行了驗證。這就是我在Firebug中看到的:http://www.myupload.org/files/h75nj0oaqz876skqavgz.png – limbovski 2010-07-27 18:44:17

0
$.post('lol', { starta:'1', currenta:'5', finisha:'2', startb:'1', currentb:'5', finishb:'2', startc:'1', currentc:'5', finishc:'2', startd:'1', currentd:'5', finishd:'2', starte:'1', currente:'5', finishe:'2', startf:'1', currentf:'5', finishf:'2', startg:'1', currentg:'5', finishg:'2', starth:'1', currenth:'5', finishh:'2', starti:'1', currenti:'5', finishi:'2', startj:'1', currentj:'5', finishj:'2', startk:'1', currentk:'5', finishk:'2', startl:'1', currentl:'5', finishl:'2', startm:'1', currentm:'5', finishm:'2', startn:'1', currentn:'5', finishn:'2', starto:'1', currento:'5', finisho:'2', startp:'1', currentp:'5', finishp:'2', startq:'1', currentq:'5', finishq:'2', startr:'1', currentr:'5', finishr:'2', starts:'1', currents:'5', finishs:'2', startt:'1', currentt:'5', finisht:'2' }) 

上面的代碼工作正常,POSTS正確與正確的數據對我來說。如何提供更多信息?