document.body.appendChild(jForm) won‘t work because jForm is not a dom element, it is a jQuery object so add the below script before jForm.submit(); jForm.appendTo(‘body‘) function loadPage(url, projectName) { var jForm = $(‘<form></form>‘, { action: url, method: ‘post‘ }); $("<input>", { name: ‘curPrj‘, value: projectName }).appendTo(jForm); jForm.appendTo(‘body‘).submit(); }
var form = $("<form method=‘post‘></form>"), input; form.attr({ "action": url }); $.each(args, function (key, value) { input = $("<input type=‘hidden‘>"); input.attr({ "name": key }); input.val(value); form.append(input); }); form.appendTo(‘body‘).submit();
时间: 2024-11-07 17:37:37