jQuery的,从PHP收到读JSON变量变量、jQuery、PHP、JSON

由网友(爽歪歪)分享简介:抱歉,如果这是基本的,但我一直在处理搞清楚了这一点一整天,已经得到的地方,我所能做的一切,我需要使用jQuery和CakePHP(不知道CakePHP的事项本或者其任何PHP一样),我想回到从CakePHP的功能,jQuery的一个变量,我读了有关如何做到这一点,喜欢这里:Sorry if this is basic...

抱歉,如果这是基本的,但我一直在处理搞清楚了这一点一整天,已经得到的地方,我所能做的一切,我需要使用jQuery和CakePHP(不知道CakePHP的事项本或者其任何PHP一样),我想回到从CakePHP的功能,jQuery的一个变量,我读了有关如何做到这一点,喜欢这里:

Sorry if this is basic, but I have been dealing with figuring this out all day and have gotten to where I can do everything I need with Jquery and cakephp (not sure if cakephp matters in this or if its same as any PHP), I want to return a variable from a cakephp function to jquery, I had read about how to do it, like here:

CakePHP的:

$test[ 'mytest'] = $test;
 echo json_encode($test);

和jQuery的:

$.ajax({
  type: 'POST',
  url: 'http://localhost/site1/utilities/ajax_component_call_handler',
  data: {
        component_function: component_function,
        param_array: param_array
        },
        dataType: "json",
  success: function(data) {
   // how do i get back the JSON variables? 
  }
});

我只是无法弄清楚如何获得一个或多个变量回内jQuery的有用的形式,我只是想变,所以我可以做任何其他事情,我一直在寻找什么,我可以通过搜索找到但它不是任何意见使它完全清楚,我..谢谢。

I just can't figure out how to get one or more variables back into usable form within jquery, I just want the variable so I can do whatever else with it, I've been looking at what I can find through searching but its not making it fully clear to me.. thanks for any advice.

推荐答案

您变量数据。

$.ajax({
  type: 'POST',
  url: 'http://localhost/site1/utilities/ajax_component_call_handler',
  data: {
        component_function: component_function,
        param_array: param_array
        },
        dataType: "json",
  success: function(data) {
   // how do i get back the JSON variables? 
      var values = eval( data ); //if you 100 % trust to your sources.
  }
});
阅读全文

相关推荐

最新文章