var values= {Title :title , BannerImg : bannerimgsrc ,Banneralt :bodyimgalt ,nbLink : navBarEditorLinks ,LinksEditor : links, Address : addresses};
var editorTXT =JSON.stringify(values);----This is my json String which i get when i submit my html form.I am extracting all the values from the form on submission.
alert(editorTXT);
一旦我得到这个json对象,我试图在点击保存按钮时使用.post或.ajax发布到服务器。但是当我点击保存时,这个方法完全被忽略了。请建议我如何使它工作。我正在使用jquery 1.6.2.js lib。如果我的ajax方法语法错误,请建议我。
jQuery.ajax({type:"POST", url : " mailMgtCntrlS/init",
data : { filename: filename,
cmd: cmd,
token: token,
partitionid: partitionid content_desc: content_desc, EditorDefault: editorTXT},
success :function(){ alert('successful'); var response = result.split(":"); document.saveNewsletterForm.token.value = result[1];
}, dataType:'json'});
答案 0 :(得分:2)
jQuery.ajax({
type:"POST",
url : " mailMgtCntrlS/init",
dataType:'json',
data :"JSONFile=" + { filename: filename, cmd: cmd, token: token, partitionid: partitionid content_desc: content_desc, EditorDefault: editorTXT},
success :function(result,msg){
alert(msg);
alert(result.filename); // if you respose same with your post
//var response = result.split(":");
//document.saveNewsletterForm.token.value = result[1];
}
});
我建议
$.ajax
中的“JSONFile”,请参阅我的回答代码request.getParams("JSONFile");//this is in java
中的尝试像这样改变
{
"filename": "filename",
"cmd": "cmd",
"token": "token",
"partitionid": "partitionid",
"content_desc": "content_desc",
"EditorDefault": "editorTXT"
}