简体   繁体   中英

Javascript works on local server but not on live server

I have some website code that I recently uploaded onto my live server and it seems as though my JavaScript function is not working. I searched this site as well as Google and I cannot find a solution, so I am posting this question. I have checked and double checked my directory links and they are being found okay. I did run firebug and it does not post any errors, it's only when I selected the "all" tab is shows me a "500 Internal Server Error". It points me to one line within my JavaScript function, which I've checked to make sure the syntax is correct and it seems good. Again, on my local WAMP server everything works fine, even in firebug it confirms that it works as expected.

Here is the line that firebug points me to:

xmlhttp.send("FLD="+fld+"&TBL="+tbl+"&CAT="+cat+"&ID="+id+"&POS="+pos+"&URL="+url+"&DEL="+del);

It shows that I have all fields present, so everything is being passed to the function okay.

Here is the full function itemDelete() code:

function itemDelete(name,fld,tbl,cat,id,pos,url,del)
{
var check = confirm('Are you sure you want to delete the item "'+name+'" ?');
    if(check === true)
        {
        if (window.XMLHttpRequest)
          {// code for IE7+, Firefox, Chrome, Opera, Safari
          xmlhttp=new XMLHttpRequest();
          }
        xmlhttp.onreadystatechange=function()
          {
          if (xmlhttp.readyState==4 && xmlhttp.status==200)
            {
            window.location.reload();
            // Below is the code needed to retrieve the echo statements from itemMgmt.php
            // Be sure to comment out the reload statment above
            // document.getElementById("response").innerHTML=xmlhttp.responseText;
            }
          }
        xmlhttp.open("POST","/admin/process/itemMgmt.php",true);
        xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
        xmlhttp.send("FLD="+fld+"&TBL="+tbl+"&CAT="+cat+"&ID="+id+"&POS="+pos+"&URL="+url+"&DEL="+del);
        }
}

And here is the button code that triggers this function:

<input type="button" style="margin-top:10px;" value="DELETE THIS ITEM" onclick="itemDelete('<?php echo str_replace('_',' ',$music['Item_Name']);?>','Item_ID','music','music','<?php echo $music['Item_ID']; ?>','<?php echo $music['Item_Pos']; ?>','<?php echo $url; ?>','item')">

Once the function itemDelete() is triggered, it goes to itemMgmt.php which actually deletes the item. As far as I can tell the process is not making it to itemMgmt.php .

Any idea?

You answered yourself: 500 Internal Server Error . Check the server logs.

It's most likely not related to Javascript, but some configuration issue on the server. Exactly what is impossible to say without details from server logfiles.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM