Ajax stopt met werken

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Jimmy Arts

jimmy Arts

11/11/2010 23:50:13
Quote Anchor link
Hey.
Ik had eerst een ajax functie gemaakt met javascript maar toen heb ik die geprobeerd te perfectioneren zodat ik hem vaker kan gebruiken maar nu doet hij helemaal niets meer.
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function xmlhttpPost(strURL,Result_id,Form_name,Media_id,Input_id) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText, Result_id);
        }
    }
    self.xmlHttpReq.send(getquerystring(Form_name,Media_id,Input_id));
}

function getquerystring(Form_name,Media_id,Input_id) {
    var form     = document.forms[Form_name];
    var word = form.Input_id.value;
    qstr = 'value=' + escape(word) + '&media_id=' + Media_id;  // NOTE: no '?' before querystring
    return qstr;
}

function updatepage(str,Result_id){
    document.getElementById(Result_id).innerHTML = str;
}

Dit is de originele code:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function xmlhttpPost(strURL) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {
            updatepage(self.xmlHttpReq.responseText);
        }
    }
    self.xmlHttpReq.send(getquerystring());
}

function getquerystring() {
    var form     = document.forms['playlist'];
    var word = form.playlist_id.value;
    var media = form.media_id.value;
    qstr = 'playlist=' + escape(word) + '&media_id=' + media;  // NOTE: no '?' before querystring
    return qstr;
}

function updatepage(str){
    document.getElementById("playlist_result").innerHTML = str;
}

Zo roep ik hem aan:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
<input type="button" name="add" value="Toevoegen" onclick='JavaScript:xmlhttpPost("functions/playlist.php","playlist_result","playlist","<?php echo $media_id; ?>","playlist_id")' />
 
PHP hulp

PHP hulp

20/04/2024 10:02:10
 
Jimmy Arts

jimmy Arts

13/11/2010 13:50:23
Quote Anchor link
iemand?
 
The Force

The Force

13/11/2010 14:05:52
Quote Anchor link
Installeer Firebug in Firefox en kijk wat voor foutmelding hij geeft. Aan 'er gaat iets fout' hebben wij en jij niets.
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.