相关疑难解决方法(0)

jQuery版本1.5 - ajax - <script>标记时间戳问题

如果我使用带有脚本标记的ajax(jQuery)加载一些内容,jQuery 1.5会将时间戳添加到脚本标记src url中.见下面的例子.

示例:我用ajax加载的内容:

<div>text1</div>
<script type="text/javascript" src="/js/abc-xyz.js?r=1.1"></script>
Run Code Online (Sandbox Code Playgroud)

这是我将以前的内容插入页面后加载脚本代码的src网址:

.../js/abc-xyz.js?r=1.1&_=1297892228466
Run Code Online (Sandbox Code Playgroud)

有人知道为什么会这样吗?它只发生在jQuery 1.5上.jQuery 1.4.4不会发生这种情况.

代码示例:

$.ajax({
    url: content.html,
    type: 'GET',
    data: someDataObject,
    success: function(data) {
        // some code here

    },
    error: function(data) {
        // some code here
    }
});
Run Code Online (Sandbox Code Playgroud)

谢谢.

javascript ajax jquery timestamp jquery-1.5

13
推荐指数
2
解决办法
4325
查看次数

使用will_paginate gem在rails 3.2.3中调用Ajax

我试图用will_paginate gem实现一个Ajax调用,我发现这个指南http://ramblinglabs.com/blog/2011/11/rails-3-1-will_paginate-and-ajax这似乎是一个简单的解决方案,尽管它包括我不熟悉的coffeescript,所以如果有人有不同的解决方案,请告知..

我的代码如下

我的看法

<div class="container">
 <div class="row">
  <div id="userRecipes">
   <%= render partial: 'userrecipes' %>
 </div>
</div><!--/row-->
Run Code Online (Sandbox Code Playgroud)

我的部分(userrecipes)

 <% @recipes.each do |r| %>
  <div class="span3">
   <div class="thumbnail">
    <%= image_tag r.avatar.url(:myrecipes) %>
   </div>
   <h4><%= link_to r.dish_name, r %></h4>
   <hr>
    <p><%= truncate r.description, :length => 90 %></p>
    <p><%= link_to "Edit Recipe", edit_recipe_path(r.id) %></p>
    <p><%= link_to "Delete Recipe", recipe_path(r.id), :confirm => "Are you sure?", :method => :delete %></p>
    <p><%= link_to "Add to favorites",  {:controller => 'favourites', :action => 'create', :recipe_id => …
Run Code Online (Sandbox Code Playgroud)

ajax ruby-on-rails partial-views coffeescript ruby-on-rails-3

3
推荐指数
1
解决办法
1万
查看次数

使用will_paginate Rails 4进行Ajax请求

我一直在阅读SO上的一些帖子,看看其他人是如何处理这个并且我正在使用的实现几乎在那里但是在第三个链接请求后失败,会发生什么是重新加载页面而不是触发ajax请求.我也删除了Turbolinks,但这并没有什么不同.

这是我的设置,我认为js在某个地方失败了,因为我的jQuery不是那么强大我希望有人可以帮忙

Index.html.erb

<div class="facebook_ajax">
  <%= render 'shared/posts' %>
</div> 
Run Code Online (Sandbox Code Playgroud)

共享/ _posts.html.erb

<% @posts.each do |p| %>
<article class="post">
<%= image_tag('/assets/vandals_fb_profile.jpg') %>
<%= link_to 'Varsity Vandals', "https://www.facebook.com/VarsityVandals", target: 'blank' %>
<%= date_output(p.created_time) %>
  <figure>
    <% if p.large_image_url? %>
      <%= image_tag(p.large_image_url) %>
    <% end %>

    <% if p.video_url? %>
      <%= raw youtube_embed(p.video_url) %>
    <% end %>
  </figure>
  <p><%= p.message.gsub("\n", "<br>").html_safe %></p>
    <% if p.description? %>
      <p><%= p.description %></p>
    <% end %>
    <%= link_to 'Read More', p.link %>
</article>
<hr/>
<% end …
Run Code Online (Sandbox Code Playgroud)

ruby jquery ruby-on-rails will-paginate ruby-on-rails-4

3
推荐指数
1
解决办法
2278
查看次数