drcmue4619 2014-10-05 18:07
浏览 31

如何通过Ajax获取php返回值?

Im creating a validation form in Ajax and PHP. But i don't have a clue how i should get the value from PHP??

For example:

The validation form is in index.php And the page with the function is checkUser.php. In checkUser i have a global file included with my classes initialized. The checkUser.php look like this:

<?php

$requser = false;
require "core/rules/glb.php";

$user->checkUser($_GET['username']);

The get function comes from the Ajax call i do in the index file. But how do i know that PHP said that the username already exist så that i can make a if statement and paus the script?

Im a beginner, thanks.

And sorry for my english

                                        $.ajax({

                                            type: "GET",
                                            url: "user_add.php",
                                            data: 'username='+$("#jusername").val()+'&email='+$("#jemail").val()+'&password='+$("#jpassword").val()+'&secureSession=23265s"',
                                            success: function()
                                            {
                                                location.href='register.php';
                                            }
                                        });
  • 写回答

2条回答 默认 最新

  • dongshan8194 2014-10-05 18:18
    关注

    Jus print out the data, for better help also post the ajax script

    <?php
    
        $requser = false;
        require "core/rules/glb.php";
    
        print $user->checkUser($_GET['username']);
    
    评论

报告相同问题?