Maybe this should be moved to the Javascript/AJAX forum!
I have the below snippets of code, the problem is i can't get status to pass into the changeCaseStatus.php page, it just gives a blank value all the time???
show.php - <script type="text/javascript" language="javascript">
-
var loading_img = \'../../images/layout/loading.gif\';
-
var loading_msg = \' Loading Data...\';
-
var xmlhttp_obj = false;//create the XMLHttpRequest
-
-
function ewd_xmlhttp()
-
{
-
if (window.XMLHttpRequest)
-
{ // if Mozilla, Safari etc
-
xmlhttp_obj = new XMLHttpRequest();
-
}
-
else if (window.ActiveXObject)
-
{ // if IE
-
try
-
{
-
xmlhttp_obj = new ActiveXObject("Msxml2.XMLHTTP");
-
}
-
catch (e)
-
{
-
try
-
{
-
xmlhttp_obj = new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
catch (e)
-
{
-
-
}
-
}
-
}
-
else
-
{
-
xmlhttp_obj = false;
-
}
-
-
return xmlhttp_obj;
-
} //get content via GET
-
-
function getcontent(url)
-
{
-
var xmlhttp_obj = ewd_xmlhttp();
-
document.getElementById(containerid).innerHTML = \'<img src="\' + loading_img + \'" />\' + loading_msg;
-
xmlhttp_obj.onreadystatechange=function()
-
{
-
loadpage(xmlhttp_obj);
-
}
-
xmlhttp_obj.open(\'GET\', url, true);
-
xmlhttp_obj.send(null);
-
alert(xmlHttp.responseText);
-
window.location.href = \'../../cases/'.$_REQUEST['id'].'/\';
-
}
-
-
function loadpage(xmlhttp_obj, containerid)
-
{
-
if ( xmlhttp_obj.readyState == 4 && xmlhttp_obj.status == 200 )
-
{
-
document.getElementById(containerid).innerHTML = xmlhttp_obj.responseText;
-
}
-
}
-
//]]>
-
</script>
-
...
-
<select name="status" onchange="getcontent(\'../../sys_config/changeCaseStatus.php?id='.$cid.'&s=\'this.value\');"">'.getCaseStatusList().'</select>
changeCaseStatus.php - changeCaseStatus($_GET['id'],$_GET['status']);
9 1381 Atli 5,058
Expert 4TB
Hi.
Your function "loadpage" takes two parameters, the AJAX object and the ID of an element, which you use inside it to print the AJAX result.
On line #44, you call this function, but you don't pass it the second parameter, which means that your code doesn't have an element to put the AJAX response into.
And you also do this on line #41. You try to get an element using the variable "containerid", which I can't find anywhere.
In addition to that, the URL only has a parameter "s" set, not "status" as expected in the PHP file.
Ok, I'm trying this now with no luck: - <script type="text/javascript">
-
function changeCaseStatus() {
-
var xmlHttp;
-
try {
-
// Firefox, Opera 8.0+, Safari
-
xmlHttp=new XMLHttpRequest();
-
}
-
catch (e) {
-
// Internet Explorer
-
try {
-
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
-
}
-
catch (e) {
-
try {
-
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
catch (e) {
-
alert("Your browser does not support AJAX!");
-
return false;
-
}
-
}
-
}
-
function getcontent(url)
-
{
-
xmlHttp.onreadystatechange=function() {
-
if(xmlHttp.readyState==4) {
-
xmlHttp.responseText;
-
}
-
window.location.href = \'../../cases/'.$_REQUEST['id'].'/\';
-
xmlHttp.open(\'GET\', url ,true);
-
xmlHttp.send(null);
-
}
-
}
-
}
-
</script>
-
...
-
<select name="status" onchange="getcontent(\'../../sys_config/changeCaseStatus.php?id='.$cid.'&status=\'+this.value);">'.getCaseStatusList().'</select>
- changeCaseStatus($_GET['id'],$_GET['status']);
I'm not sure what you're trying to do. When you set window.location.href, the page will change to the new location. That will mean the Ajax call will be ignored.
Bascily when the select box has been changed that it will call the page changeCaseStatus.php and pass the id and status vairables to it, then it will refresh back to the current page to show the change of status, does that explain it?
The 'hi' alert is show up now and the page is refreshing but it wont retrieve the details on the changeCaseStatus.php page?? - <script type="text/javascript">
-
function getcontent(url)
-
{
-
var xmlHttp;
-
try {
-
// Firefox, Opera 8.0+, Safari
-
xmlHttp=new XMLHttpRequest();
-
}
-
catch (e) {
-
// Internet Explorer
-
try {
-
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
-
}
-
catch (e) {
-
try {
-
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
catch (e) {
-
alert("Your browser does not support AJAX!");
-
return false;
-
}
-
}
-
}
-
-
alert("hi");
-
xmlHttp.onreadystatechange=function() {
-
if(xmlHttp.readyState==4) {
-
xmlHttp.responseText;
-
}
-
}
-
xmlHttp.open(\'GET\', url ,true);
-
xmlHttp.send(null);
-
window.location.href = \'../../cases/'.$_REQUEST['id'].'/\';
-
}
-
</script>
-
...
-
<select name="status" onchange="getcontent(\'../../sys_config/changeCaseStatus.php?id='.$cid.'&status=\'+this.value);">'.getCaseStatusList().'</select>
changeCaseStatus.php -
<?php
-
session_start();
-
include_once('../../database.php');
-
include_once('../../sql_query.php');
-
-
dbConnect();
-
-
changeCaseStatus($_GET['id'],$_GET['status']);
-
-
closeConnect();
-
?>
Okay, got it working fine on my local machine but when i upload it to the next it doesn't work, any ideas?
The whole purpose of Ajax is to avoid reloading the page. If that's not a requirement, then there's no need to use Ajax.
Yup, i know what i did wrong now! :D Thanks.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Yarco |
last post by:
I want to use "Ajax" to create my web for hobby.
But i don't know whether "Ajax" is mature...
And what about with php? Someone have experience on it?
....
|
by: bobzimuta |
last post by:
I'm creating a simple AJAX library. It's an object that will return an
array containing the response text or xml. I'm trying to find a way to
assign the response as a property of the object, but...
|
by: wangzx |
last post by:
I am the author of easyajax.sourceforge.net, and I have a problem on
Firefox 1.5, I post the problem here and hopes somebody help me.
The test page can be:...
|
by: melledge |
last post by:
Ajax Developers' Day added to XTech 2006 agenda
XTech 2006 - 17-19 May - Hotel Grand Krasnopolsky - Amsterdam, The
Netherlands
|
by: melledge |
last post by:
Ajax Developers' Day to Kick Off XTech 2006 Conference
Industry experts offer insight into next generation of the Web
ALEXANDRIA, VIRGINIA, USA - April 25, 2006 - In response to the
rapidly...
|
by: www.web20developers.com |
last post by:
http://www.web20developers.com
http://www.web20developers.com/index.php?option=com_content&task=view...
Ajallerix : AJAX, simple, fast Web image gallery demo ; at Novell
AJAX -...
|
by: preeti13 |
last post by:
i have a two tables employeenominations and reason if someone storing a data first time it will store into the employeenominations table if name is already exist it will store into the reason table...
|
by: shaunwo |
last post by:
I'm an AJAX / DOM Novice (at best) and trying to figure out how to write the value to a couple input fields. I don't remember exactly where I got the ajax.js file I'm using from (went to the website...
|
by: prarthanaraut |
last post by:
Hi,
I am getting Browser problerm while using AJAX in classic ASP code.
I want to execute some asp code when user clicks on checkboxes on one page
without refreshing the page.
I have...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |