Questions about variables and loop statements

Source: Internet
Author: User
For more information about variables and loop statements, I 'd like to ask about AJAX and PHP. now I want to click a tag on the front-end page, the following figure shows my associated information about the tag clicked above. the code is as follows: index. php & lt; html & gt; & lt; head & gt; & lt; script & nbsp; about variables and loop statements
Hello, everyone, I want to ask a question about AJAX and PHP. now I have encountered such a situation.
I hope that when clicking a tag on the front-end page, the information about the tag I clicked above will be displayed below. the code is as follows:
Index. php


《script》 






Suggestions: 





Js clienthint code
var xmlHttp

function showHint(str)
{
if (str.length==0)
  { 
  document.getElementById("txtHint").innerHTML=""
  return
  }
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request")
  return
  } 
var url="gethint.php"
url=url+"?q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)


function stateChanged() 

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("txtHint").innerHTML=xmlHttp.responseText 

 } 
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 // Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}

Processing page code gethint. php
  $q=$_GET["q"];

//$select ="select * from test where cid='$q'";

$hint="for($i=0;$i<2;$i++){......}";

//Set output to "no suggestion" if no hint were found
//or to the correct values
if ($hint == "")
{
$response="no suggestion";
}
else
{
$response=$hint;
}

//output the response
echo $response;
?>

Because $ hint needs to be uploaded to the front-end page during processing, I want to pass the loop content after processing the page, but I write as follows: $ hint = "for ($ I = 0; $ I <2; $ I ++ ){......} "; but it only transmits the file string.
Is there any good solution?
Online, etc. thank you! Share:
------ Solution --------------------
It may be:
Not matching
Duplicate id
The pre-bound event is invalid.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.