Php ajaxpost的样式结果
我最近遇到了一个问题。我有一个脚本,通过ajax post将一个项目添加到我的Opencart的购物车中,并将结果添加到一个div中。然而,我似乎得到了一个与设置响应不同的响应Php ajaxpost的样式结果,php,jquery,ajax,post,opencart,Php,Jquery,Ajax,Post,Opencart,我最近遇到了一个问题。我有一个脚本,通过ajax post将一个项目添加到我的Opencart的购物车中,并将结果添加到一个div中。然而,我似乎得到了一个与设置响应不同的响应 "Success: You have added <a href="%s">%s</a> to your <a href="%s">shopping cart</a>!" 我只是一个初学者,所以如果可能,请提供详细信息 非常感谢您得到了一个json响应,要获得成功消息,
"Success: You have added <a href="%s">%s</a> to your <a href="%s">shopping cart</a>!"
我只是一个初学者,所以如果可能,请提供详细信息
非常感谢您得到了一个json响应,要获得成功消息,您需要这个-
$("#addform").submit(function() {
$.post($("#addform").attr("action"), $("#addform").serialize(), function(data){
// parse json response
data = $.parseJSON(data);
// get success message with data.success and append it to results
$("#result").empty().slideDown("slow").append(data.success);
});
return false;
});
删除“”将导致完全相同的响应。添加成功不会导致任何响应,但会将项目添加到购物车中,以便收到表单。非常感谢:)效果非常好@万万干杯!
$(document).ready(function(){
$("#addform").submit(function() {
$.post($("#addform").attr("action"), $("#addform").serialize(), function(data){
$("#result").empty().slideDown("slow").append(data);
});
return false;
});
});
$("#addform").submit(function() {
$.post($("#addform").attr("action"), $("#addform").serialize(), function(data){
// parse json response
data = $.parseJSON(data);
// get success message with data.success and append it to results
$("#result").empty().slideDown("slow").append(data.success);
});
return false;
});