带有ajax内容的滑块 [英] Slider with ajax content

查看:58
本文介绍了带有ajax内容的滑块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个jquery滑块,默认情况下它是关闭的.因此,当用户尝试打开并发送ajax请求时,数据就来了.我的问题是每次用户关闭并打开ajax请求时都会发送.那么我如何才能第一次进行Ajax调用,如果用户关闭并打开滑块则如何保留数据?

I have a jquery slider, its like on default it is closed. So when the user try to open and ajax request is send and the data comes. My problem is each time the user closes and opens the ajax request is send. so how can i make the ajax call for the first time and if the user closes and opens the slider how to retain the data?

推荐答案

您可以设置变量,例如:

You can set a variable, for example:

var alreadySent = false;

然后在您的ajax回调函数中将其更改为true(假设您使用的是jQuery post):

then in your ajax callback function you can change it to true (assuming you are using jQuery post):

if (!alreadySent) {
  $.post("address", params, function(data) {
    // do something
    alreadySent = true;
  });
}

这篇关于带有ajax内容的滑块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆