对不起,我使用rails 2.3.8。 我在弹出窗口中有一个远程表单。这使用JavaScript代码提交帖子,因为我需要在多部分帖子。好?远程ajax请求中的问题
的部分,在弹出的形式是:
$j(document).ready(function() {
$j('#product_submit').click(function(event) {
event.preventDefault();
$j('#uploadForm').ajaxSubmit({
beforeSubmit: function(a, f, o) {
o.dataType = 'json';
},
complete: function(XMLHttpRequest, textStatus) {
// XMLHttpRequest.responseText will contain the URL of the uploaded image.
// Put it in an image element you create, or do with it what you will.
// For example, if you have an image elemtn with id "my_image", then
// $('#my_image').attr('src', XMLHttpRequest.responseText);
// Will set that image tag to display the uploaded image.
}
});
});
});
{:controller => "products", :action => "create_starred_product"}, :html => {:method => :post, :id => 'uploadForm', :multipart => true} do |f| %>
Nombre: "textarea" %>
Precio: "textarea" %>
Imagen
"file-upload" -%>
Descripción 10, :class => "textarea clearfix" -%>
"product_submit" %>
我控制器
def create_starred_product
product = Product.new(params[:product])
if product.valid? && product.save
render :update do |page|
#puts in the page the name of product
page.replace_html 'star-product', :partial => "admin/products/star_product_name", :locals => {:star_product => product}
#Close the popup. I use $j for conflict between JQuery and Prototype
page.call "$j.modal.close"
end
else
end
end
但是完成动作时,我有在Firebug的控制台这个错误:
s.error.call (s.context,xhr,'error',e);
so render:update不更新我的页面。
注意:我正确保存产品。
为什么会出现此错误?
预先谢谢