Jump to content

[SOLVED] What wrong in my code?


deepson2

Recommended Posts

Hello,

 

I just want someone to look into my code and tell me what i am doing wrong here. earlier i have used the same function to delete record with ajax. but it seems here its not working.

 

Here is my code.

 

PHP Code:

 

 

<div>

<?for ($j = 0; $j <$blogcount; $j++) {

            $blogid= $blogid1[$j];

           echo "<ul id='nav'><li><a href='/blogs/".$blogurl[$j]."'>".ucfirst(strtolower(stripslashes($bloglist[$j]))). "</a><ul><li><a href ='javascript:remove($blogid);' title='Delete'>X</a></li></ul></li></ul>";

        }

        ?>



</div>

Js code

 

 

 

function remove(blogid){

  alert("hello");

// Configure those variables as appropriate

var divid = 'status';
var url = 'deletefav.php';
  alert("hello1");


// The XMLHttpRequest object

var xmlHttp;
try{
xmlHttp=new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari
}
catch (e){
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("Your browser does not support AJAX.");
return false;
}
}
}

// Generate timestamp for preventing IE caching the GET request

fetch_unix_timestamp = function()
{
return parseInt(new Date().getTime().toString().substring(0, 10))
}

var timestamp = fetch_unix_timestamp();
  alert("hello2");

var nocacheurl = url+"?t="+timestamp;


// This code sends the variables through AJAX and gets the response

xmlHttp.onreadystatechange=function(){

if(xmlHttp.readyState!=4){

document.getElementById(divid).innerHTML='<img src="images/spinner.gif">  Wait...';
}
if(xmlHttp.readyState==4){
document.getElementById(divid).innerHTML=xmlHttp.responseText;
}
}
  alert("hello4");

xmlHttp.open("GET",nocacheurl+"&blogid="+blogid,true);
xmlHttp.send(null);


// Finally, some code for button toggle

var button = document.getElementById('button');

switch(button.name)
{
case 'button0':
  button.src = 'images/1.jpg';
  button.name = 'button1';
  break;
case 'button1':
  button.src = 'images/0.jpg';
  button.name = 'button0';
  break;
}

}

 

Thnaks in advance.

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.