ajax请求无法发送整个查询

时间:2016-05-05 22:10:35

标签: jquery ruby-on-rails ajax

我有这个ajax请求

$.ajax({
    type: "GET",
    url: "/tracks/tweetaction?id=" + $("#artist_id").val() + "&link=" + url + "&message=" + prepopulated_tweet ,
    success: function (data) {
      getPageLink(url);
    }
  });

问题在于prepopulated_tweet。由于某种原因而不是发送此

  

@Myrfriends @RndomPerson"你会喜欢这首曲目" @Krilex - Pieces -   Red #Rock #Pop #Soul Krilex。****。co / rx11

它发送此

  

@Myrfriends @RndomPerson \"你会喜欢这首曲目\#34; @Krilex - Pieces -   红色

请求就像这样

Started GET "/tracks/tweetaction?id=1&link=http://localhost:3000/artists/1?refid=3d4e1145-7d02-42a0-87f0-aa5f992dfe9b&trackid=1
&message=@Myrfriends%20@RndomPerson%20%22you%27ll%20love%20this%20track%22%20@Krilex%20-%20Pieces%20-%20Red"

这里有什么不对吗?

1 个答案:

答案 0 :(得分:2)

这样做似乎解决了我的问题

prepopulated_tweet = encodeURIComponent(prepopulated_tweet)