Jump to content

Trouble getting values passed.


Catp00p

Recommended Posts

I am using ajax to update a div on my page. 

 

The form to call the ajax script:

<form name='updateTrainForm' method='post' onsubmit='return false;'><input type='hidden' name='skill_id' value='$skill_id'><button type='submit' class='train' onclick='doTrainUpdate();'>Train Now</button></form>

 

The Ajax:

function doTrainUpdate()
{
  var xmlHttp = getXMLHttp();
  
  xmlHttp.onreadystatechange = function()
  {
    if(xmlHttp.readyState == 4)
    {
      HandleResponse(xmlHttp.responseText);
    }
  }

  xmlHttp.open("POST", "train.php", true); 
  xmlHttp.setRequestHeader("cache-control", "no-cache");
  xmlHttp.send(null);
}

function HandleResponse(response)
{
document.getElementById('trainUpdate').innerHTML = response;
}

 

In train.php, the value is not passed.

$skill_id = $_POST["skill_id"];

 

 

I'm guessing i have to somehow pass the values through the js, but I don't know java at all.  Any pointers?

Link to comment
https://forums.phpfreaks.com/topic/174017-trouble-getting-values-passed/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.