简体   繁体   中英

how to return data from php to ajax success call

nali.php

$tagId = mysqli_insert_id($link);
  echo $tagId; 

at ajax success call

$.ajax({
        url: "nail.php",
        type: "post",
        data: {Tag:tag},
        success: function(data) {
            $enter_tag_id = data.tagId;
           alert(data);
        }
    });

i get the correct echo at php page . but not get any value at ajax success.i want to save tagId to a variable at ajax success

Update your ajax code: success: function(data) { //$enter_tag_id = data; alert(data); } success: function(data) { //$enter_tag_id = data; alert(data); }

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