Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
AJAX problem i opera

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Client-side
View previous topic :: View next topic  
Author Message
Gale



Joined: 04 Apr 2005
Posts: 120

PostPosted: 02.02.2006 00:09    Post subject: AJAX problem i opera Add user to your forum ignore list Reply with quote

Koristim ovu jednostavnu skriptu za neke stvari na svom sajtu:

Code:

var page = '';
var element = '';
function loading(e){
   element = e;
    document.getElementById(element).innerHTML = 'pričekajte trenutak...';
}
function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function sndReq(action, p) {
   page = p;
    http.open('get', page+'?action='+action);
    http.onreadystatechange = handleResponse;
    http.send(null);
}

function handleResponse() {
    if(http.readyState == 4){
        var response = http.responseText;
        document.getElementById(element).innerHTML = response;
    }
}


Skripta radi u IE-u i Firefoxu ali ne u Operi.
Kako se naziva XMLHttpRequest u Operi ?

Hvala
Back to top
View user's profile Send private message Visit poster's website
imbrod
Guest





PostPosted: 02.02.2006 10:23    Post subject: Reply with quote

Sorry, stvarno ne znam nista o AJAXu, ali koliko sam citao, Microsoft veli da postoji zasad podrska samo za IE i FF.

Recimo, otvori www.start.com u IE i u Operi.
Back to top
maratz
mi3.crew


Joined: 24 Nov 2003
Posts: 1207
Location: ZAG

PostPosted: 02.02.2006 11:30    Post subject: Add user to your forum ignore list Reply with quote

Ne radi ti zato kaj snifaš browser, umjesto da detektiraš podršku za metodu, kako se to normalno i radi. (op.a. dostupnost novih tehnologija dopušta svatkome da se bavi stvarima bez osnovnog predznanja).

Opera se po defaultu predstavlja kao IE, ali ne podržava ActiveXObject, prema tome tvoja varijabla http ostaje 'undefined'. Također, po defaultu, varijabla ro ako ne prođe, returnat će ti 'undefined', što je dost nezgodna vrijednost.

Ovo bi trebalo raditi:
Code:
var http = function() {
    var ro = null; /* s ovim si ziher da će ti returnat null ako ne prođe niti jedan uvjet */
    if (window.XMLHttpRequest) {
        ro = new XMLHttpRequest();
    } else if(window.ActiveXObject) {
        var msp = new Array('Msxml2.XMLHTTP','Microsoft.XMLHTTP');
        for (var i = 0; i < msp.length; i = i + 1) {
            try { ro = new ActiveXObject(msp[i]); } catch (e) {};
        };
    };
    return ro;
};

a također i dio:
Code:
function sndReq(action, p) {
    http.open('get', p + '?action=' + action, true); /* iako je po defaultu true, hoće zahengat, ako se explicitno ne pošalje i taj argument */
    http.onreadystatechange = handleResponse;
    http.send(null);
};


U svakom slučaju, pročitati o JavaSciptu

_________________
STOP HITTING YOURSELF! | NETIQUETTE | TYPETESTER | Hypertext rulez™ | CREATIVE NIGHTS | ACCOMMODATIONS
Back to top
View user's profile Send private message Visit poster's website Twitter profile
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 03.02.2006 13:52    Post subject: Add user to your forum ignore list Reply with quote

sad će uletit chevap i reći da mu Ajax ne radi u Firefoxu Razz
Back to top
View user's profile Send private message Send e-mail Visit poster's website
che.UP
mi3.crew


Joined: 07 Sep 2003
Posts: 2320
Location: zagreb

PostPosted: 03.02.2006 14:08    Post subject: Add user to your forum ignore list Reply with quote

ja to kazem svakim svojim postom :)

_________________
UP | TypeTester | Accommodations App
Meni u Firefox-u ne radi AJAX
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Client-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group