AJAX Call to PHP file: return value is empty

后端 未结 2 547
一向
一向 2021-01-23 12:39

I have a simple ajax call:

function init() {
    $.ajax({
        url: \"./myFolder/user.php\",
        data: {
            action: \"init\"
        },
        t         


        
相关标签:
2条回答
  • 2021-01-23 13:14

    u should have in your user.php somthing like this:

    die(init());
    
    0 讨论(0)
  • 2021-01-23 13:25

    On user.php page you need to do :-

    function init() {
            $arr = array(
                array(
                    "region" => "valore",
                    "price" => "valore2"
                ),
                array(
                    "region" => "valore",
                    "price" => "valore2"
                ),
                array(
                    "region" => "valore",
                    "price" => "valore2"
                )
            );
    
            echo  json_encode($arr);
        }
    
    0 讨论(0)
提交回复
热议问题