Questions about variables and circular statements

Source: Internet
Author: User
Questions about variables and circular statements
Daniel, the news wants to ask a question about Ajax and PHP, and now I have a situation like this
I want the front-end page to click on a tag, below can display my information about the above click on the tag to associate the data, the code is as follows
index.php













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;
}

Handling 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 the processing page $hint is needed to upload to the front page, so I hope that the processing page will loop the content is done after the transfer, but I wrote: $hint = "for ($i =0; $i <2; $i + +) {...}"; He can only pass the file string.
So please, do you have any good solutions?
Online, etc., thank you all!

Share to:


------Solution--------------------
May be:
Tag does not match
Duplicate ID
Invalid pre-bound event

  • 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.