日期:2014-05-16  浏览次数:20388 次

jquery的Ajax返回值怎么取?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="jquery-1.8.0.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        var test = {
            getValue: function (key) {
                if (key == '1') {
                    return 'A';
                } else {
                    return 'B';
                }
            },
            getAjaxValue: function (key) {
                $.ajax({
                    type: "post", async: false, cache: false, dataType: "text",
                    url: '../../Handler/JavaScriptSession.ashx',
                    data: [
                    { name: "action", value: "read" },
                    { name: "name", value: key },
                    { name: "value", value: "" }
                    ],
                    success: function (result) {
                        if (result != "error" || result != "true") {
                            alert("内部"+result);//这值能得到,并成功alert出
                            return "返回值"+result;
                        }
                &