开发者

Use jQuery to replace form params with a JSON object on submit

How w开发者_Go百科ould you code the function replaceFormParamsWithJsonObject(jsonObject)?

$('#myForm').submit(replaceFormParamsWithJsonObject(jsonObject));


Not sure exactly what you're after but something like this?

$.each(jsonObject, function(key, value)
{
    $(this).find('input:[name=' + key + ']').val(value);
});

This will update the form inputs with names corresponding to the object's keys.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜