0

I am using zend framework project which is been created by using zend studio. Also there is a Jquery project which is created separately.

I have deployed jquery project in tomcat, and on click of one button in jquery, a php method is called by using ajax LOAD method. PHP is returning string value.

However, for some reason data is not coming back to jquery method.

 Jquery method:




 var res =  $('#updatedtime').load("http://test/index/returndate");

PHP method

public function returndateAction(){
  $this->_helper->viewRenderer->setNoRender(true);//this will do job

   return "hi";

 }

Can we use jquery LOAD method be used to get data? Please correct me if am wrong!

Thanks all

4

3 回答 3

0

客户端不知道也不关心你在服务器端运行什么。您可以从服务器获取任何您想要的东西,无论是使用 PHP 创建的东西,还是静态资源。

如果您没有取回数据,请使用浏览器的网络工具来验证是否正在发出请求以及是否正在返回数据。此外,请确保您实际上是在服务器端执行该功能。看来你不是。

于 2012-12-03T03:50:58.617 回答
0

是的,只需添加一个回调函数作为第二个参数.load

$('#updatedtime').load("http://test/index/returndate", function (phpString) { ... }); 
于 2012-12-03T03:50:59.420 回答
0

你的意思是这样的:PHP

public function returndateAction(){
  $this->_helper->viewRenderer->setNoRender(true);//this will do job
  echo "hi";
}

jQuery

// data from PHP is displayed in your element having id updatedtime
$('#updatedtime').load("http://test/index/returndate"); 

或者

$('#updatedtime').load("http://test/index/returndate", function(data){
    alert(data); //shows 'hi'
}); 

检查您尝试通过负载访问的 url 是否实际被调用。

于 2012-12-03T03:50:24.507 回答