简体   繁体   中英

ajax form redirects to server page?

I got this ajax form that when submitted, should send the info to the server, the server, based on the info sent should decide a form to send back, and then the ajax function should load that form into the page, and the user should be none the wiser of the coolness in the background. The form submits, the php and stuff processes it fine, sends back this cool object, but then it seems to be stuck on the page on the server that was processing it, and then links to a page that just shows the returned info. Not cool. Here's the code:

     $(document).ready(function() { 

        $("#game").ajaxForm(function(json) {
            if(json.status == 'OK') {
                $("#game").html(json.form);
            }else {
                $(".error_msg").html(json.msg);
            };
        });

    });

What should happen, is that the function rewrites the json.form to the correct div tag, but instead it goes straight to a page that just outputs the json object itsself. Any help would be greatly appreciated, and if you guys need more info, just ask! Thanks a lot!

JSON本身将作为对象返回,您必须对其进行解码/解析才能正确显示。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM