如何选择一个又一个用ajax jquery的响应时,标签如何选择、标签、ajax、jquery

2023-09-10 14:03:35 作者:清醒的人最荒唐

当表单淡出然后选择另一个选项卡,这也是jQuery的标签

  $。阿贾克斯({
    网址:URL_STRING,

    // GET方法
    键入:POST,

    //传递数据
    数据:data_string,

    //不要缓存页面
    缓存:假的,

    //成功
    成功:函数(HTML){
        //如果process.php返回1 /真(发送邮件成功)
        如果(HTML代码!=){
            //隐藏窗体
            $('表')淡出(慢)。

            //这里的功能无法正常工作...

            $(函数(){
                $(#tabmenu)。标签(#内容,{
                    效果:阿贾克斯,
                    当前:主动,
                    initialIndex:1
                });
            });
        } 其他 {
            警报('对不起,意外错误,请稍后再试。);
            返回false;
        }
    }
});
 

解决方案

  $(函数(){
 $(#tabmenu)。标签(#内容,{
   效果:阿贾克斯,
   当前:主动,
   initialIndex:1
 });
});
 
温故jQuery Ajax,你会有新的发现

从改变你的code以上,以下。

  $(#tabmenu)。标签(#内容,{
  效果:阿贾克斯,
  当前:主动,
  initialIndex:1
});
 

我想这不能开除你的标签,因为DOM,在这个非常时刻,是加载。

When form fade out then select another tab which is also jquery tab

$.ajax({
    url: url_string,

    //GET method is used
    type: "POST",

    //pass the data         
    data: data_string,

    //Do not cache the page
    cache: false,

    //success
    success: function (html) {
        //if process.php returned 1/true (send mail success)
        if (html != "") {
            //hide the form
            $('.form').fadeOut('slow');

            // here the function is not working...

            $(function () {
                $("#tabmenu").tabs("#content", {
                    effect: 'ajax',
                    current: 'active',
                    initialIndex: 1
                });
            });    
        } else {
            alert('Sorry, unexpected error. Please try again later.');
            return false;
        }
    }
});

解决方案

$(function () {
 $("#tabmenu").tabs("#content", {
   effect: 'ajax',
   current: 'active',
   initialIndex: 1
 });
}); 

Change your code from that above to that below.

$("#tabmenu").tabs("#content", {
  effect: 'ajax',
  current: 'active',
  initialIndex: 1
});

I guess it can't fire your tabs because the DOM, in this very moment, is loading.