开发者

Calling a php function by an jquery ajax request and updating a div by the return object

I have a div and some labels in it. The labels show information by a given php object's properties.

I want to update that object by an ajax request in every 3 seconds and then update the div by the newest objec开发者_StackOverflow中文版t's properties.

How can I do that ? Actually I am curious about calling the function and reading return object's properties in the jquery ajax function. I can handle other parts.

Thanks in advance,


You can use setInterval something like this:

var interval = setInterval(yourAjaxFun, 3000);

where the function yourAjaxFun does updating you need.

You can clear the interval any time later using:

clearInterval(interval);

From your php code, you can use json_encode function on your object to return it as JSON so that you can parse the returned response using jQuery JSON parsing function eg parseJSON

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜