# "syntax error, unexpected tIDENTIFIER  , expecting kEND" in RJS 	response

**URL:** <https://discuss.rubyonrails.org/t/syntax-error-unexpected-tidentifier-expecting-kend-in-rjs-response/36627>\
**Category:** rubyonrails-talk\
**Created:** [November 22, 2008, 9:38pm UTC](https://discuss.rubyonrails.org/t/syntax-error-unexpected-tidentifier-expecting-kend-in-rjs-response/36627 "2008-11-22T21:38:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jawosis](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@jawosis](https://discuss.rubyonrails.org/u/jawosis)\
**Post date:** [November 22, 2008, 9:38pm UTC](https://discuss.rubyonrails.org/t/syntax-error-unexpected-tidentifier-expecting-kend-in-rjs-response/36627/1 "2008-11-22T21:38:06Z")

</div>

I get a "syntax error, unexpected tIDENTIFIER, expecting kEND" when the following RJS template is rendered:

page.insert\_html :bottom, :requisite\_table, :partial =\> "insert\_jobrequisite\_select", :locals =\> {:job =\> @job, :counter =\> @counter} page.alert("hi")

The same RJS template is rendered without errors as soon as the rjs file has only one single javascript call - that means, the prior example works if "page.alert("hi")" is deleted.

The strange thing about it is, that in another controller action I use a similar rjs template (containing two javascript calls as above) and it works.

The only difference between both rjs templates is that the problematic one (the above example) renders a template which itself calls another template within a loop over a collection (job.requisites each do |r| render :partial =\> "requisite").

Anyone knows what is going on here and how to make this problematic example work?

Thanks for any help!

Jochen

---

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [November 22, 2008, 9:46pm UTC](https://discuss.rubyonrails.org/t/syntax-error-unexpected-tidentifier-expecting-kend-in-rjs-response/36627/2 "2008-11-22T21:46:17Z")

</div>

> I get a "syntax error, unexpected tIDENTIFIER, expecting kEND" when the following RJS template is rendered:
> 
> page.insert\_html :bottom, :requisite\_table, :partial =\> "insert\_jobrequisite\_select", :locals =\> {:job =\> @job, :counter =\> @counter} page.alert("hi")
> 
> The same RJS template is rendered without errors as soon as the rjs file has only one single javascript call - that means, the prior example works if "page.alert("hi")" is deleted.
> 
> The strange thing about it is, that in another controller action I use a similar rjs template (containing two javascript calls as above) and it works.
> 
> The only difference between both rjs templates is that the problematic one (the above example) renders a template which itself calls another template within a loop over a collection (job.requisites each do |r| render :partial =\> "requisite").
> 
> Anyone knows what is going on here and how to make this problematic example work?

Bad line endings or invisible gremlins ?

Fred

---

<div class="post-metadata">

**Author:** ![jawosis](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@jawosis](https://discuss.rubyonrails.org/u/jawosis)\
**Post date:** [November 22, 2008, 10:01pm UTC](https://discuss.rubyonrails.org/t/syntax-error-unexpected-tidentifier-expecting-kend-in-rjs-response/36627/3 "2008-11-22T22:01:14Z")

</div>

Hi Fred,

what exactly do you mean by bad line endings? If there would be any bad line endings in:

a) the rjs template - then, I should see the same error in the second rjs template (the one that works) using the same syntax...which istn't the case! b) the partials being called in the rjs template - then, I should also see the error when just the first line/ javascript call (the one that calls the partials) is executed...which istn't the case!

Hmmm...then it must be the invisible gremlins?

---

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [November 22, 2008, 10:12pm UTC](https://discuss.rubyonrails.org/t/syntax-error-unexpected-tidentifier-expecting-kend-in-rjs-response/36627/4 "2008-11-22T22:12:19Z")

</div>

> Hi Fred,
> 
> what exactly do you mean by bad line endings? If there would be any bad line endings in:
> 
> a) the rjs template - then, I should see the same error in the second rjs template (the one that works) using the same syntax...which istn't the case!

Probably in the rjs template. The thing is that your editor would probably display them in the same way, so the two files would look identical even if they weren't. Your editor will have a show invisibles command and a convert line endings one too, play around with those.

Fred

---

<div class="post-metadata">

**Author:** ![jawosis](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@jawosis](https://discuss.rubyonrails.org/u/jawosis)\
**Post date:** [November 23, 2008, 11:09am UTC](https://discuss.rubyonrails.org/t/syntax-error-unexpected-tidentifier-expecting-kend-in-rjs-response/36627/5 "2008-11-23T11:09:32Z")

</div>

Ok - thanks a lot for your advice Fred!

I checked my line endings with another editor and in fact found some unwanted whitespaces. Now everything works fine!
