由于某种原因,我无法在MySQL中获取使用Ajax更新的记录。记录是VARCHAR(1000)。必须存在语法错误。但我看不到它。我尝试了一切 - 任何想法?谢谢 !
$(".edit_comment").change(function(){
var comment = $(".edit_comment").val() // This is just text from a text box.
var $id = $("#customer_id").val();
$.ajax({
headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
type: "POST",
url: 'update_comment/'+$id,
data: comment,
success: function () {
console.log(comment, $id); // I can see the correct text & id here
alert('Your Comment is Updated')
},
error: function () {
alert('there has been a system level error - please contact support')
}
});
Laravel控制器:
public function update_comment(Request $request, $id){
$comment = $request->get('edit_comment');
Quotation::where('id', $id)
->update(['comment' =>$comment]);
}
答案 0 :(得分:1)
我认为数据应该是
data: {edit_comment: comment}
或者,现在可以在php结束时获取数据。
$comment = $request->get('edit_comment');