可以将getJSON()用于php吗? [英] can getJSON() be used for php?

查看:122
本文介绍了可以将getJSON()用于php吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是通过单击加载的JQuery代码,但回调函数不起作用:

This is the JQuery code loaded over click but the callback function isn't working:

$.getJSON("load_img.php", {"id":"start"} , function(json){
     alert(json);
});

PHP代码为我提供了以下输出:

PHP code gives me this output:

[
    {"img_name":"shiva.jpg","img_id":"1"}, 
    {"img_name":"shiva.jpg","img_id":"2"},
    {"img_name":"Recoverd_jpg_file(4).jpg","img_id":"3"}, 
    {"img_name":"Recoverd_jpg_file(542).jpg","img_id":"4"}
]

我无法从getJSON()函数加载任何PHP页面...我从[这里] [1]下载了示例源代码

I cannot load any PHP pages from getJSON() function...i downloaded sample source code from [here][1]

[1]: http://www.sitepoint.com/ajaxjquery-getjson-simple /并已在浏览器上运行它,但仍无法正常工作... 任何帮助将不胜感激!!谢谢

[1]: http://www.sitepoint.com/ajaxjquery-getjson-simple/ and have run it on browser but it doesnt work still... any help would be much appreciated!!!Thank you

推荐答案

我今天得到了答案...没有<html>标记应包含在要输出的代码中...它应该只包含开始和结束的php标签,即

I got my answer today...no <html> tags should be included in the code to be outputted... it should only contain starting and ending php tags i.e.

<?php
//your code or codes
?>

这篇关于可以将getJSON()用于php吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆