Toon posts:

[javascript] verstuur GET waarden naar externe pagina

Pagina: 1
Acties:

Verwijderd

Topicstarter
Hallo,

Is het mogelijk een externe pagina met javascript te requesten zonder te open of alleen een get waarden te sturen.

bogus voorbeeld!!
code:
1
open.window.noshow :) (testPagina.php?testWaarde=hallo );


Ik weet dat dit mogelijk is met ajax maar is hiervoor ook een ander functie of optie beschikbaar??

Heb al gezocht op google maar weet niet precies hoe ik dit moet zoeken.

Alvast bedankt!!

[ Voor 3% gewijzigd door Verwijderd op 20-05-2005 12:14 ]


  • BtM909
  • Registratie: Juni 2000
  • Niet online

BtM909

Watch out Guys...

Nee, is alleen mogelijk met de wondere feature XMLHTTPRequest (vind de naam AJAX maar niks :X)

Ace of Base vs Charli XCX - All That She Boom Claps (RMT) | Clean Bandit vs Galantis - I'd Rather Be You (RMT)
You've moved up on my notch-list. You have 1 notch
I have a black belt in Kung Flu.


Verwijderd

Topicstarter
zeg XMLHTTPRequest maar 50 keer heel snel en dan neem je vanzelf het A woord in je mond.

Wel je mond wassen daarna.

Ik ga het dan wel met XMLHTTPRequest oplossen

iig bedankt voor je reactie

****** TOPIC CLOSED ************

Verwijderd

Schrijf het dan tenminste op de goede manier. (Als in XMLHttpRequest.) 'Ajax' — irritante term, maar briljant voor marketing — is overigens meer dan alleen dat object.

Verwijderd

Topicstarter
Erg leuk ben nu met action triggering bezig voor een communicatie site werkt echt perfect. maakt gebruik van dit script (http://twilightuniverse.com/2005/05/sack-of-ajax/) hieronder een voorbeeldje.

Dit script hieronder loopt automatisch en kijkt of de waardes van de laatste id verschillen als ze verschillen haalt hij de acties op en voert ze uit.

action zetten: setAction.php?action=getTest|dit is de alert text

setAction.php bevat gewoon een standaard insert scriptje:
insert into ajactions (action) values ('$_GET[action]');

in de getAction() wordt de naam van de funtie "getTest" uit de database via eval aangeroepen. alles wat je in action zet wordt als functie aangeroepen.


Wat linkies!!:
http://www.ajaxblog.com/
http://www.ajaxian.com/
http://www.ajaxmatters.com/

PHP:
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
33
34
switch ($_POST[action]){
 case "checkActions":
 getLastAction();
 break; 
 case "getActions":
 getActions($_POST[lastId]);
 break; 
}

function getLastAction(){
  global $conn_id;
  $query="select * from ajactions order by Id desc limit 1";
  $result=mysql_query($query, $conn_id) or die('er gaat iets four'.mysql_error());
 
  $row=mysql_fetch_array($result);
  $res=$row[Id];
  echo $res;
}


function getActions($id){
  global $conn_id;
 
  $query="select * from ajactions where Id > $id";
  $result=mysql_query($query, $conn_id);

  $i=0;
 
  while($row=mysql_fetch_array($result)){
    $res.="actions[$i]='$row[Id]|$row[action]'\n";
    $i++;
  }
  echo $res;
}


javascript sectie
JavaScript:
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<html>
<head>
<script type="text/javascript" src="sacks.js"></script>
<script type="text/javascript">
 
  function timer(){
      setInterval('readArray()', 10000);
    }

    function getActions(lastId){
   
    var mydata = 'action=getActions&lastId='+lastId;
      ajaxs = new sack('doSomething.php');
      ajaxs.onCompletion = getAction;
      ajaxs.runAJAX(mydata);
    }

    
    function getAction(){
      actions = new Array();  
      var i = 0;
      eval(ajaxs.response);
      
      for (i=0; i<actions.length; i++){
       action=actions[i].split("|");
       eval(action[1]+'(action[2])');
      }
  }
  
  function getTest(test){
    alert(test);
    }   

    
    function getArray(){
   
    var mydata = 'action=checkActions';
      ajaxx = new sack('doSomething.php');
      ajaxx.onCompletion = getArrays;
      ajaxx.runAJAX(mydata);
    }
    
    function getArrays(){
      action=ajaxx.response;
  }
    
    function readArray(){
    var mydata = 'action=checkActions';
      ajax = new sack('doSomething.php');
    ajax.onCompletion = myFn;
    ajax.runAJAX(mydata);
    }
    
     function myFn(){
      var check = ajax.response;
      if (check!=action){
        getActions(action)
       }
       getArray(); 
  }
    
</script>
</head>
<body onload="timer(); getArray()">
</body>
</html>

[ Voor 11% gewijzigd door Verwijderd op 20-05-2005 12:49 ]