<script type="text/javascript">
$('#eventForm').submit(function (e) {
e.preventDefault();
var fd = new FormData(this);
var msg =document.getElementById('msg').value;
var data = {};
data.message = msg;
$.ajax({
url: '/messages/<%= id %>',
data: data,
dataType: "JSON",
type: 'POST',
success: function(data){
alert();
$("ul").append('<li class="message left appeared">hgdfhgjdhfjghdfj</li>');
// console.log(JSON.stringify(data));
}
});
});
</script>
并在控制器中发布数据。它成功发布并插入数据,但li不附加。在控制台中没有错误。
BASE.APP.post('/messages/:id',BASE.urlEncodedParser, function(req,res)
{
var body = req.body;
var msgdata ={
"contactID" : req.params.id,
"message" : body.message,
"token" : req.usersession.token
}
var digest = BASE.utils.hmac("sha1", "A12AA418-1F28-4464-8B67-29CBD02BC45C-F048B14F-F3E3-4F97-A522-F2275A364A0E", JSON.stringify(msgdata));
var sendData = {
"contactID" : req.params.id,
"token" :req.usersession.token,
"message":body.message,
"digest" : digest
};
//console.log(sendData);
var textPostdata = BASE.utils.base64encode(BASE.utils.base64encode(JSON.stringify(sendData)));
// console.log(textPostdata);
BASE.request({
url : "http://example.com/sendTextMessage/",
method :"POST",
headers : {
"content-type": "application/json",
},
body : textPostdata
},
function (err,result,body) {
//console.log(typeof body);
var textbody = JSON.parse(body);
res.send('controller success');
});
});
我想在此附加
但它没有显示任何东西,而我常常警告它没有成功 jquery的一部分