Javascript not working

Status
Not open for further replies.

scr99x10

New Member
Messages
4
Reaction score
0
Points
1
Hello,

I have a free account and I recently uploaded a website. When I test it locally Javascript works fine, but when I test it on the host some js functions go wrong. I also noticed on the File Manager, that the Javascript files I uploaded have type "text/x-generic". What might be wrong? Any suggestions?

Thank you.
 

Dead-i

x10Hosting Support Ninja
Community Support
Messages
6,084
Reaction score
368
Points
83
Hi,

Please can you provide me with a link to your webpage? JavaScript is rendered entirely client-side, so there should be no difference with it being on a hosting server. :)

Thank you,
 

caftpx10

Well-Known Member
Messages
1,534
Reaction score
114
Points
63
Any hints that indicate that there is JavaScript code not correctly being executed? All I see that is wrong according to the console is that the page is requesting a non-existing image.
 

scr99x10

New Member
Messages
4
Reaction score
0
Points
1
In the following function only the ajax call works, but it gets as parameter comment an empty string even when I type in the input text.

function addComment(pid,t,m,mid,pmid){

$('#commentbuttongif').html('<img id="ajaxcommentgif" src="ajax-loader.gif" />');
document.getElementById("commentbutton").disabled = true;
var comment = $("#comment").val();
var commentcount = parseInt(document.getElementById('inputcommentcount').value) +1;
$.ajax({
type:'post',
url:'addcomment.php',
data:{pid:pid,
comment:comment,
pmid:pmid,
t:t},
dataType:'json',
success:function(data){

$("#newcomment").prepend($('<div id="c'+data['2']+'" class="row"><div class="col-xs-6 col-md-5 col-md-offset-2"><h4><a href="membersposts.php?x='+mid+'&m='+m+'">'+m+'</a><small> '+data['0']+'['+data['1']+']:</small></h4><h5>'+ comment+'</h5></div><div class="col-md-1"><button data-toggle="tooltip" data-placement="bottom" title="Delete" class="btn btn-default btn-xs pull-right" onclick="return deleteComment('+data['2']+','+pid+');"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button></div></div><div class="row" id="h'+data['2']+'"><div class="col-xs-6 col-md-6 col-md-offset-2"><hr></div></div>').fadeIn('slow'));
document.getElementById('comment').value = '';
$("#commentcount").html('<h4>Comments ('+commentcount+')</h4><form action=""><input type="hidden" id="inputcommentcount" value="'+commentcount+'"/></form>');
document.getElementById("commentbutton").disabled = false;
$('#ajaxcommentgif').remove();
}
});
return false;
}

In the next function the ajax call doesn't work but the commands inside the response function work (so when I reload the page no changes are made).

function deleteComment(commentID,postID){
var commentcount = parseInt(document.getElementById('inputcommentcount').value) -1;//this also works
$.ajax({
type:'post',
url:'deletecomment.php',
data:{cid:commentID,
pid:postID},
success: function(response){
$("#c"+commentID).remove();
$("#d"+commentID).remove();
$("#h"+commentID).remove();
$("#commentcount").html('<h4>Comments ('+commentcount+')</h4><form action=""><input type="hidden" id="inputcommentcount" value="'+commentcount+'"/></form>');
}

});

return false;
}

The above code has been tested locally and it works. Does it has to do with configuration settings or mime types (maybe)?

Thank you.
 

caftpx10

Well-Known Member
Messages
1,534
Reaction score
114
Points
63
Would this be on an other page? I cannot find such code on the login page (where the link points towards).
 

scr99x10

New Member
Messages
4
Reaction score
0
Points
1
Ok. It wasn't javascript after all. Some php errors that stored and returned wrong values through ajax. Thank you for your time.
 
Status
Not open for further replies.
Top