[英]i am trying to call back a string in PHP JQUERY
I am trying to call back the value of content_columns to jquery. 我正在尝试将content_columns的值回调给jquery。
PHP CODE: PHP代码:
if($act=="getcol"){
$pid=$_GET['pid'];
$domain_id = 1;
$PAGEresult = mysql_query("SELECT * FROM pages WHERE domain_id='$domain_id' AND id='$pid' ORDER BY id DESC");
$PAGErow = mysql_fetch_array($PAGEresult);
echo json_encode($PAGErow['content_columns']);
}
jQuery jQuery的
$.get("get_actions.php?act=getcol&pid="+pid, function(data){
alert(data);
});
Can someone lead me down the right path please. 有人可以引导我走正确的道路。
If by "same string" it is possible that it is cached. 如果使用“相同字符串”,则有可能被缓存。 You can disable caching with jQuery's ajax library that you are using. 您可以使用正在使用的jQuery的ajax库禁用缓存。 You can also send a different query string such as with the system time to ensure you don't get a cached results. 您还可以发送其他查询字符串(例如,系统时间),以确保不会得到缓存的结果。 You can also use POST. 您也可以使用POST。
You will only ever get one result from that query. 您只会从该查询中获得一个结果。 If you want multiple results, you need to iterate over mysql_fetch(). 如果要获得多个结果,则需要遍历mysql_fetch()。 If you only want one result, add LIMIT 1 to your query. 如果只需要一个结果,请在查询中添加LIMIT 1。 Otherwise it is incredibly wasteful. 否则,这是非常浪费的。 Finally, why use SELECT *? 最后,为什么要使用SELECT *? Use SELECT content_columns .. 使用SELECT content_columns ..
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.