2

HTML 5を使用してページコンテンツを編集可能にし、後で使用するためにデータをjsonファイルに保存しようとしていました。

また、編集された部分とjsonファイルを変更するphpファイルだけをAJAXを使用してページがロードされることも望んでいます。

これに関する情報は本当に役に立ちます。

これまでのところ、最初の AJAX から AJAX PHP JSON を調べてきましたが、それに関連するかなりの知識がありますが、知っておく必要があるのは、次のような形式の JSON ファイルからそれを行う方法です -

{
    "itemGuitar": {
        "id": "itemGuitar",
        "description": "Pete Townshend once played this guitar while his own axe was in the shop having bits of drumkit removed from it.",
        "price": 5695.99,
        "urls": [
            "thewho",
            "Pete_Townshend"
        ]
    },
    "itemShades": {
        "id": "itemShades",
        "description": "Yoko Ono's sunglasses. While perhaps not valued much by Beatles fans, this pair is rumored to have been licked by John Lennon.",
        "price": 258.99,
        "urls": [
            "beatles",
            "johnlennon",
            "yoko-ono"
        ]
    },
    "itemCowbell": {
        "id": "itemCowbell",
        "description": "Remember the famous \"more cowbell\" skit from Saturday Night Live? Well, this is the actual cowbell.",
        "price": 299.99,
        "urls": [
            "Saturday_Night_Live",
            "More_cowbell"
        ]
    },
    "itemHat": {
        "id": "itemHat",
        "description": "Michael Jackson's hat as worn in the \"Bille Jean\" video. Not really rock memorabilia, but it smells better than Slash's tophat.",
        "price": 1699.99,
        "urls": [
            "abc",
            "def"
        ]
    }
}

ajaxを使用して編集されたデータを取得し、phpを使用してjsonで変更し、ajaxを使用してデータをWebページに再度ロードするのに助けが必要です。

このjsonはファイルに保存されます。

前もって感謝します!!

ガウラフ・ナガル

これまでの HTML は --

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test HTML to save content editable on the go!!</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
  function sendData () {
    var val = document.getElementById('editMe').innerHTML;

    var cuenta = new Object();
       cuenta.editMe     = val;

    $.ajax({
         type: 'post'
       , url: '/processDataFilePHP.php'
       , dataType: 'json'
       , data: { cuenta: editMe }
       });

  }
</script>
</head>
<body>
<h1 id="editMe" contenteditable="true">Hurray!!!</h1>
<button id="save" type="submit" onclick="sendData()">Save</button>
</body>
</html> 

また、json に保存され、php によって返される新しいテストを交換する方法も知りたいです。

4

1 に答える 1