Jump to content

[SOLVED] New to ajax


adam291086

Recommended Posts

I got some ajax script of another forum and i am trying to implement it into my script. Here is the ajax part

 

function createRequestObject()
{
var request_o; //declare the variable to hold the object.
var browser = navigator.appName; //find the browser name
if(browser == "Microsoft Internet Explorer"){
	/* Create the object using MSIE's method */
	request_o = new ActiveXObject("Microsoft.XMLHTTP");
}else{
	/* Create the object using other browser's method */
	request_o = new XMLHttpRequest();
}
return request_o; //return the object
}
/* Function called to handle the list that was returned from the internal_request.php file.. */
function handleThoughts(){
/* Make sure that the transaction has finished. The XMLHttpRequest object 
	has a property called readyState with several states:
	0: Uninitialized
	1: Loading
	2: Loaded
	3: Interactive
	4: Finished */
try
{
	if(http.readyState == 4){ //Finished loading the response
		/* We have got the response from the server-side script,
			let's see just what it was. using the responseText property of 
			the XMLHttpRequest object. */
		var response = http.responseText;
		//alert(response);
		if(response!="ok")
		{
			alert("Please select another username!");
		}

	}
}
catch(Exception)
{
}

}

 

i then have a javascript function that uses the above functions to run my php script

 

function update_database(el)

{
    var height;

    var width;

    var top; 

    var left;
    var Div_name;
    var Border;
    var Position;
    var Background;
    var Cursor;


    height = el.style.height;
alert(height);
    if(height == '')
    {
      height = '100px';
    }

    width = el.style.width;
    if(width == '')
    {
      width = '100px';
    }


    top = el.style.top;
    if(top == '')
    {
      top = '0px';
    }


    left = el.style.left;
    if(left == '')
    {
      left = '0px';
    }

    Div_name = el.id;
    Border = el.style.border;
    Position = el.style.position;
    Background = el.style.background-color;
    Cursor = el.style.cursor;
    
    var http = createRequestObject();
http.open('get', 'update.php?height=' + height + '?width'+width + '?top'+top + '?left'+left + '?Div_name'+Div_name + '?Border'+Border + '?Position'+Position + '?Background'+Background + '?Cursor'+Cursor);
http.send(null);

}

 

this is the php script

 

<?php

include('config.php');
$left = $_GET["left"];
$top = $_GET["top"];
$height = $_GET["height"];
$width = $_GET["width"];
$Position = $_GET["Position"];
$Background = $_GET["Background"];
$Cursor = $_GET["Cursor"];
$Border = $_GET["Border"];
$div_name = $_GET["Div_Name"];

$conn;
mysql_query("UPDATE Admin_Page_Style SET Style_Left = '$left',Style_Top = '$top',Style_Height = '$height',Style_Width = '$width',Style_Position = '$Position',Style_bgcolor = '$Background',Style_Cusor = '$Cursor',Border = '$Border',div_name = '$div_name',
WHERE div_name = 'div3'");

?>

 

but my database dosn't update. What am i doing wrong,

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.