Jump to content

onClick via A HREF


MikeDXUNL

Recommended Posts

When a user click "Owned" it should move it to their owned List.... thats not the case though...

actions.js

var xmlHttp

function newadd(str2, str3, str4)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="ajax/whattodo.php";
url=url+"?gameid="+str2"&whereto="+str3"&type_q="+str4;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}



function stateChanged() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("txtHint7").innerHTML=xmlHttp.responseText;
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

 

 

myfile.php

<div id="txtHint7"></div>
<a href="#" onClick="newadd('<?php echo $gameid; ?>', 'Owned', 'videogames')">Owned</a>

 

whattodo.php

$gameid = (!isset($_GET['gameid']) || !is_numeric($_GET['gameid'])) ? "0" : $_GET['gameid'];



echo $gameid."<br />";
echo $_GET['whereto']."<br />";
echo $_GET['type_q']."<br />";

 

 

however nothing happens, any help is appreciated :)

btw, I am new to JS and AJAX :P

 

Thanks,

Mike

Link to comment
Share on other sites

Doesn't look like there is anything wrong with your code.  Watch out for paths, make sure that var url="ajax/whattodo.php"; is the correct path to the whattodo.php file. 

 

The best thing for debugging Ajax is to download Firefox, if you don't already have it and download the Firebug plugin.  This shows you the calls and what is updated on the page.   

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.