Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6944971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:22:33+00:00 2026-05-27T13:22:33+00:00

That might be a silly question. Sorry if that’s the case. On a rails

  • 0

That might be a silly question. Sorry if that’s the case.

On a rails 3 application with the latest jquery-rails gem “1.0.12” I am trying to replace html from an ajax call

$.ajax({
    type: "POST",
    cache: false,
    url: url,
    data: data,
    error: function(jqXHR, textStatus, errorThrown){
        console.log(jqXHR);
        console.log(textStatus);
        console.log(errorThrown);
    },
    success: function(msg){
        alert('Load was performed.');
    }
    });

From the controller I answer the ajax call with htm code from a js.erb file
the content of the js.erb file is

<img src="<%=@test%>" id="<%=@test_id%>">

The response is received but parseerror error is triggered.
The content type in the header of the response is

Content-Type:text/javascript; charset=utf-8

the jqXHR response in the error callback contains this

Object
abort: function ( statusText ) {
always: function () {
complete: function () {
done: function () {
error: function () {
fail: function () {
getAllResponseHeaders: function () {
getResponseHeader: function ( key ) {
isRejected: function () {
isResolved: function () {
overrideMimeType: function ( type ) {
pipe: function ( fnDone, fnFail ) {
promise: function ( obj ) {
readyState: 4
responseText: "<img src="/images/author_tests/copywriter_photo_2.jpg" id="copywriter-test-4e1c3eb5e09c1657fb000003">"
setRequestHeader: function ( name, value ) {
status: 200
statusCode: function ( map ) {
statusText: "parsererror"
success: function () {
then: function ( doneCallbacks, failCallbacks ) {
__proto__: Object

I tried setting the dataType to text but by doing so the server throws an error

ActionView::MissingTemplate (Missing template [.....] with {:locale=>[:"en-US", :"en-US"], :handlers=>[:rhtml, :rxml, :builder, :haml, :erb, :rjs], :formats=>[:text, "*/*"]}

What I am doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:22:34+00:00Added an answer on May 27, 2026 at 1:22 pm

    What you are returning is actually HTML, not JS. The contents of a js.erb file is passed to the javascript engine for evaluation, so it is choking on your HTML (since that is not valid javascript).

    Since you just want to return HTML, and you want to replace an element on the page, try the jQuery .load() method, and give your URL an extension of .html. Then move the contents of your .js.erb file into whatever responds to the html format for your controller.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might be a very silly / stupid question, but, my defence is that
that might be some kind of a silly question for you guys, but anyways:
this might be a silly question, but well. I have the following code that
This might come across as a very silly question. I am trying to place
if this is a silly question, am sorry about that. I was wondering if
That might be silly question but I really need to know the answer. If
That might be a naive git question but here it is: Before doing a
I am going to ask a question that might sound weird. Is there a
I'm back with another (possibly) silly question. sorry. I have a pretty complicated query
This might be a silly question, but here goes: Is there a standard or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.