我能通过Ajax(jquery)阅读吗?

时间:2010-01-07 19:43:16

标签: javascript jquery json

我需要调用服务器AJAX方式,只需要获得1个参数:

我必须通过JSON执行此操作吗? 或者,我可以像普通的HTML页面一样拍摄,如下所示:

4

6

然后,JavaScript能够读取该行吗? 如果是这样,我怎么能用jQuery做到这一点?

2 个答案:

答案 0 :(得分:1)

不,您不必使用JSON,如果需要,可以将纯文本返回到AJAX请求。

$.get (
    'your_script',
    {
        // parameters
    },
    function ( response ) {
        // whatever you return on the server will be in the response variable
    }
);

答案 1 :(得分:1)

您可以使用jQuery.ajax

$.ajax({
  url: "foo.php",
  success: function(msg){
    alert(msg); // alerts 4 or 6
  }
});