How to use Jq,ajax to return to the previous page and refresh __ajax

Source: Internet
Author: User

Today, I'm going to tell you a little about how to go back to the page and refresh the data.

Problem: After the user submits the form to the data, return to the View list presentation layer.

There's wood, hurrying feet, it's easy to say, here the small partners may say that use a simple window.history.go (-1) method to return to, the last page, indeed, so, you can return directly to the previous page, but we carefully check the data, whether you found that the changes you made , not on the page can be displayed, only to refresh the page, you can change it.

here, the small knitting carefully inquires the window.history.go (-1) method Introduction:

Window.history.go (-1) is to return the previous page
Window.location.go (-1) is to refresh the previous page 

All of them are locally saved session values, not dynamically obtained.

The final small series after a few filtered, finally got the answer:

Self.location = Document.referrer;
**document.referrer Overlay * * In terms of

usage document.referrer want to be able to trace the browser-side behavior. If a page A is opened, then the browser side of the action that may occur is user action, JS code two kinds.
! [Write a picture description here] (https://img-blog.csdn.net/20160728160207155)
$ (". Form-horizontal"). Ajaxform ({
        type: "POST",
        Data: $ (this). Serialize (),
        dataType: "JSON",
        Beforesend:function () {
        },
        success:function (data) {
            //alert (data.status);
            if (data.status = = 1) {
                //window.location.go ( -1);
                Self.location = Document.referrer;
                $ (this). attr (' Data-url ', data.url);
                $ ("#bl_id"). Val (data.id);
                document.getElementById (' Extrabuton '). Click ();
            else {
                alert (data.info);
            }
        },
        error:function (data) {
            fillmessagetomodal ("<span class= ' Text-danger ' > Error </span> ', transform (Data.responsejson));
            Messagemodal.modal (' show ');
            Autoclosemessagemodal ();
        }
    );

Here, the small part of the form submitted, it will return to the previous page, and make a refresh,
Small partners, there is no understanding, do not know small partners, can be private small series Oh, welcome contributions.
Also welcome the big God, to the younger brother's code to put forward opinion, the younger brother will humbly be educated.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.