AJAX Query

Status
Not open for further replies.

ziycon

New Member
I'm able to get my ajax working by passing the variables in the url like:

Code:
<input type="submit" value="Submit" onclick="getcontent('page.php?var='+this.value, 'cpost');"/>
But I'm wondering how I would go about retreiving values on 'page.php' that aren't posted via the link, I want to use something like POST as certain characters will break the link, so the link will be like:
Code:
<input type="submit" value="Submit" onclick="getcontent('page.php', 'cpost');"/>
I'm using louie's code(http://www.eire-webdesign.ie/blog/2007/11/13/dependant-select-box-using-ajax/http://www.eire-webdesign.ie/blog/2007/11/13/dependant-select-box-using-ajax/) as a guide! ;)

Any ideas?
 

ziycon

New Member
Thanks for that louie, got it working perfectly, quick one for you. On the code for the loadpage function, do you need to pass in the content to it, the only reason I ask is because I can't see where or if its needed in this function?
Code:
function loadpage(xmlhttp_obj, content, containerid){
    if ( xmlhttp_obj.readyState == 4 && xmlhttp_obj.status == 200 ){
        document.getElementById(containerid).innerHTML = xmlhttp_obj.responseText;
    }
}
 

ziycon

New Member
Having another slight issue. Basically if there is a special character it will display fine on the page when you first go to the page but when you submit something new and the AJAX reloads the data on screen all special characters show up as unrecognised. Is there a way to handle special characters in AJAX properly, data is stored in a UTF-8 database??
 

ziycon

New Member
It's only on a local dev server at the moment. Found a way around it though, I'm using the PHP function utf8_encode() for data thats returned via the AJAX query and all characters are displaying fine now. Thanks again for your help.
 
Status
Not open for further replies.
Top