Hello everyone, I posted this Monday [URL=”http://www.webdeveloper.com/forum/showthread.php?t=227236&highlight=replace”]as a reply
Basically, I am running an Ajax/PHP combo that uses PHP to make a MYSQL query and returns the results live in the search box. The problem is that all ampersands are being returned as HTML code. E.G. & returns & Is there a way to properly replace that code back to an ampersand?
Here is the javascript function that performs the retrieval of contents from PHP (PHP only returns text):
[CODE]//Called when the AJAX response is returned.
function handleSearchSuggest() {
if (searchReq.readyState == 4) {
var ss = document.getElementById(‘search_suggest’)
ss.innerHTML = ”;
var str = searchReq.responseText.split(“n”);
for(i=0; i < str.length – 1; i++) {
//Build our element string. This is cleaner using the DOM, but
//IE doesn’t support dynamically added attributes.
var suggest = ‘<div onmouseover=”javascript:suggestOver(this);” ‘;
suggest += ‘onmouseout=”javascript:suggestOut(this);” ‘;
suggest += ‘onclick=”javascript:setSearch(this.innerHTML);” ‘;
suggest += ‘class=”suggest_link”>’ + str[i] + ‘</div>’;
ss.innerHTML += suggest;
}
}
}
A working example of this issue can be found at: [url]http://www.financeglobe.com/SocialNet/Markets/
Many thanks.