开发者

suggestions for json

Is the correct usage? Which one you need to use. Below I share the sample codes. I need a recommendation for.

 {
    "__bc"  : 1,
    "_payload" : null,
    "_plugin" : [.........],
    "_debug" : "on",
    "_content" : [
             开发者_运维问答             "html":{<form name=\"signin\" id=\"signin\" action=\"javascript:;\" onsubmit=\"return false\"><label id=\"username\">username:</label> <input type=\"text\" name=\"username\" id="\username\"/></form>}
                      ]
   }  

or standart html;

<form name="signin" id="signin" action="javascript:;" onsubmit="return false">
    <label id="username">username:</label> <input type="text" name="username" id="username"/>
</form>


I would use JSON. You want to keep the markup separate. jQuery has a function .data(key,value) for storing values in the DOM.

For example:

$('form').data(formdata, {name: "signin", id: "signin"});

This stores a JSON in the form element. It is retrieved by specifying the key:

$('form').data(form data); //returns {name: "signin", id: "signing"}

You should get the general idea from this example. The documentation for .data(key,value) is here.

Hope this helps.


here you can validate your json. Your's is not valid.

This should be valid:

{
    "__bc": 1,
    "_payload": null,
    "_plugin": [],
    "_debug": "on",
    "_content": {
        "html": "<formname=\"signin\"id=\"signin\"action=\"javascript: ;\"onsubmit=\"returnfalse\"><labelid=\"username\">username: </label><inputtype=\"text\"name=\"username\"id=\"username\"/></form>"
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜