Reply
AJAX truble
Old 03-16-2008, 10:19 AM AJAX truble
Average Talker

Posts: 29
Hello, I'm creating an AJAX driven site, and I have a problem... I need to have an "live" url, wich isn'c case in my simple code... I need it, because i will need to use mod_rewrite later (client's request).

Here's what I've got so far:

PHP Code:
function loadPage(page)
    {
    if (
page == "" || page == null)
        
page "home.php";
    var 
xmlHttp;
    try
        {
        
xmlHttp=new XMLHttpRequest();
        }
    catch (
e)
        {
        try
            {
            
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
            }
        catch (
e)
            {
            try
                {
                
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
            catch (
e)
                {
                
alert("Your browser does not support AJAX!");
                return 
false;
                }
            }
        }
    
    
xmlHttp.onreadystatechange=function()
        {
        if(
xmlHttp.readyState==4)
            {
            
document.getElementById("main-content-container").innerHTML xmlHttp.responseText;
            }
        }
    
xmlHttp.open("GET","content/" page,true);
    
xmlHttp.send(null);
    } 
Then I load content with "<a href='javascript:loadPage("example.php")'>test</a> " wich works just fine, but i cann't use method POST with this (or at least don't know how)... So there are multiple problems, and any help would be appriciated...

Thanks in advance
lotar_vk is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 03-17-2008, 06:38 AM Re: AJAX truble
chrishirst's Avatar
Super Moderator

Posts: 11,866
Location: Blackpool. UK
xmlHttp.open("POST","content/" + page,true);

Be aware that POST can cause problems occasionally when trying to use it with non-existant URIs (eg rewritten ones)
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to AJAX truble
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11679 seconds with 13 queries