以下の構造を持ついくつかの pois オブジェクトを含む JAVASCRIPT 配列 allPois があります。
var poi = {
title: pois[x].title,
lat: pois[x].position.lat(),
lng: pois[x].position.lng(),
html: pois[x].html
};
これは、私のサーバーを呼び出す JAVASCRIPT 関数です。
function save(){
var jsonizedData = JSON.stringify({theArray:allPois});
jQuery.ajax({
type: 'POST',
url: 'http://localhost:8000/save',
contentType:'application/json; charset=utf-8',
dataType: 'json',
data: mydata,
async: true
});
}
これは、リクエストを処理するサーバー側の機能です。
def save(request):
for object in request.POST:
my_data = simplejson.loads(object)
return none
パラメータ「html」(実際にはhtmlコードを含む)をエンコード/デコードして、サーバーに適切にロードできるようにする最良の方法は何ですか?