var pars = "{fid:'"+ ForumID + "',title:'" + Title + "',mainBody:'"+ MainBody +"',sex:'0',age:'',sTime:'',mHistory:'',telphone:'',score:'0',ExpireDays:'7',code:'',tomemberId:'0',time:'"+ Date()+"'}";
SetState(1);
$.ajax({
type: "POST",
url: "/web/topic.asmx/AddTopic",
data: pars,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(originalRequest) {
var Json = eval("(" + originalRequest.d + ")");
//alert(Json.Redirect);
if (!Json.Success) {
alert(Json.Info);
SetState(0);
}
if (Json.Redirect != null && Json.Redirect != '') {
var reUrl = Json.Redirect;
reUrl = reUrl.replace("amp;", "");
reUrl = reUrl.replace("amp;", "");
reUrl = reUrl.replace("amp;", "");
reUrl = reUrl.replace("amp;", "");
reUrl = reUrl.replace("amp;", "");
if(reUrl.indexOf('browse') >=0)
{
alert('提问成功!所述内容包含有关键字或链接,待管理员审核后可见!\n\t查看提问将进入该帖子所在板块!');
}
if(typeof(reUrl.split("&uname=")[1])=='undefined')
{
location.href ='/HtmlWeb/askjump.aspx?action=mtopic&url='+reUrl+'&nn=0&pp=0&fid='+ForumID+'';
}
var reuname=reUrl.split("&uname=")[1].split("&pwd=");
var mUrl=reUrl.split("&ref=")[1].split("&uname=");
mUrl=mUrl[0];
reuname=reuname[0];
var repwd=reUrl.split("&pwd=")[1];
if(reuname!=null || reuname!=''|| typeof(reuname)!='undefined')
{
$('#txt1').val(reuname);
$('#txt_url').val(reUrl);
$('#txt_pwd').val(repwd);
location.href ='/HtmlWeb/askjump.aspx?action=jump&url='+mUrl+'&nn='+reuname+'&pp='+repwd+'&fid='+ForumID+'';
}
else
{
location.href ='/HtmlWeb/askjump.aspx?action=mtopic&url='+reUrl+'&nn=0&pp=0&fid='+ForumID+'';
}
var adUrl = '';
try {
adUrl = Json.Data[0];
} catch (e) { }
$('TipInfo').innerHTML = '<font color="red">' + Json.Info + '</font>';
if (Json.Data.length > 2) {
} else {
}
}
} ,
error: function(x, e) {
alert(x.responseText);
SetState(0);
}
});
如果Title和mainBody 中如果有\符号就会出错
不用引号,如下试试:
var pars = {
fid: ForumID,
title: Title,
mainBody: MainBody,
sex: '0',
age:'',sTime:'',
mHistory:'',
telphone:'',
score:'0',
ExpireDays:'7',
code:'',
tomemberId:'0',
time: Date()
};
楼上正解!结贴吧!