Why do I sometimes have to refresh the page manually after an AJAX form submission?

When I do remote form submits through jQuery .submit() why do I
sometimes have to refresh the page manually to see the results?

My jQuery handler is very simple:

$("#vote_yes").click(function() {
    $("#approval").val(true)
    $(".edit_vote").submit()
});

And the link that leverages this bit of code is as follows:

<%= link_to(“Vote Yes”, @ballot, :class => “buttons”, :id => “vote_yes”)
%>

After using this link to submit the form on the page, however, sometimes
I need to refresh before I see any changes. Why is this?

On Wed, May 4, 2011 at 1:35 PM, Tom DeHart [email protected] wrote:

And the link that leverages this bit of code is as follows:

<%= link_to(“Vote Yes”, @ballot, :class => “buttons”, :id => “vote_yes”)
%>

Are you doing this locally? and you only have one instance of your
server?
For me it looks like you’re doing two requests everytime you click ‘Vote
Yes’.
One submits the form, the other redirects you to @ballot show page. Try
adding
a return false inside the click bind function. Add just redirect the
user to
@ballot
via js.

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs