# Render\_to\_string + json problem

**URL:** <https://www.ruby-forum.com/t/render-to-string-json-problem/187846>\
**Category:** Rails\
**Created:** [April 30, 2010, 9:52am UTC](https://www.ruby-forum.com/t/render-to-string-json-problem/187846 "2010-04-30T09:52:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhishek\_shukla](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/7cd45c/32.png) [@Abhishek\_shukla](https://www.ruby-forum.com/u/Abhishek_shukla)\
**Post date:** [April 30, 2010, 9:52am UTC](https://www.ruby-forum.com/t/render-to-string-json-problem/187846/1 "2010-04-30T09:52:59Z")

</div>

I am stucked at some major issue with the AjaxForm and render\_to\_string.

I am using AjaxForm for uploading images with other details since the  
Ajax  
Upload library isn’t even using Ajax. So once the form is submitted i  
need  
to call a partial and return it in a json format. but the problem is  
that  
the render\_to\_string is not working at all. In case if i am returning  
simple  
string then it’s working fine.

reference [jQuery Form Plugin](http://jquery.malsup.com/form/#file-upload)

#Server Ruby on rails  
def some\_action  
respond\_to do |format|  
@html = render\_to\_string(:partial =\> “form.html.erb”, :object =\>  
[@obj1,  
@obj2])  
json = { :success =\> “Added successfully”, :html =\> @html }  
format.html { render :json =\> json }  
end  
end

#client side  
$(“#upload”).ajaxForm({  
dataType: “json”,  
success: function(response) {  
console.log(response);  
console.log(response.html);  
});  
return false;  
});

Thanks for any help  
Abhis
