weixin_33701564 2016-08-25 07:42 采纳率: 0%
浏览 39

如何隐藏当前页面

I have a connection with my DB and my DB sends me some integer value like "1","2" or something like that.For example if my DB send me "3" I display the third page,it's working but my problem is when it displays the third page it's not hide my current page.I think my code is wrong in somewhere.Please help me

<script>
            function show(shown, hidden) {
                console.log(shown,hidden)
                $("#"+shown).show();
                $("#"+hidden).hide();
            }

            $(".content-form").submit(function(){
                var intRowCount = $(this).data('introwcount');
                var exec = 'show("Page"+data.result,"Page' + intRowCount + '")';
                ajaxSubmit("/post.php", $(this).serialize(), "", exec,"json");
                return false;
            })


            function ajaxSubmit(urlx, datax, loadingAppendToDiv, resultEval, dataTypex, completeEval) {
                 if (typeof dataTypex == "undefined") {
                    dataTypex = "html";
                }

                request = $.ajax({
                    type: 'POST',
                    url: urlx,
                    dataType: dataTypex,

                    data: datax,
                    async: true,
                    beforeSend: function() {
                        $(".modalOverlay").show();
                    },
                    success: function(data, textStatus, jqXHR) {
                        //$("div#loader2").remove();
                        loadingAppendToDiv !== "" ? $(loadingAppendToDiv).html(data) : "";
                        if (typeof resultEval !== "undefined") {
                            eval(resultEval);
                        } else {
                            //do nothing.
                        }

                    },
                    error: function() {
                        alert('An error occurred. Data does not retrieve.');
                    },
                    complete: function() {
                        if (typeof completeEval !== "undefined") {
                            eval(completeEval);
                        } else {
                            //do nothing.
                        }
                        $(".modalOverlay").hide();
                    }

                });

            }
        </script>
  • 写回答

3条回答 默认 最新

  • weixin_33701251 2016-08-25 07:45
    关注

    The second parameter passed into the show() method is a bit wrong:

    "Page' + intRowCount + '"
    

    Perhaps you meant:

    'Page' + intRowCount
    

    Edit: wait wait you pass in a string of code to ajaxSubmit? What happens inside it?

    If ajaxSubmit can use a callback, try this:

    var exec = function(data) {
        show('Page' + data.result, 'Page' + intRowCount);
    };
    
    评论

报告相同问题?