简体   繁体   English

我正在尝试在PHP JQUERY中回调字符串

[英]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.

相关问题 我正在尝试使用jquery和php更改xml文档中节点中的文本 - I am trying to change the text in a node in an xml document with jquery and php 我正在尝试在PHP中转换日期/时间字符串 - I am trying to convert a date/time string in PHP 我正在尝试将数组转换为字符串,但是php使我感到困惑? - I am trying to turn an array into string, php is confounding me though? 试图在PHP中调用jQuery-无法正常工作? - Trying to call jQuery in PHP - not working? 我正在尝试将字符串转换为php中的数组,因为我有如下所示的字符串 - I am trying to convert string into array in php as i have string like given below 我正在尝试使用 php 函数 transliterator_transliterate 但在调用它时出现错误 - I am trying to use php function transliterator_transliterate but get an error when I call it 我试图改变div的背景图像使用PHP和jquery.php变量不获取值 - I am trying to change a background image of div using php and jquery.php variable not getting the value 我试图将问题从php存储到MongoDB后端,然后从数据库中调用问题和选项 - I am trying to store questions from php into a MongoDB backend, then call the questions and options from the database 使用 php 并从 mySQL 调用值我试图调用每 16 行包含 METAL GOLD - Using php and calling values from mySQL I am trying to call every 16 rows that contain the METAL GOLD 我有一个PHP DNS查找表单,我试图在wordpress中使用它,但实际上并不会带回结果 - I Have a PHP DNS Lookup form which i am trying to use within wordpress and it will not actually bring back the results
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM