I have the Ajax call listed bellow inside a jquery function, and the ajax call is not working. I've used "alert" to debug and its like the jquery function didn't even had the ajax call. Nothing inside it is processed, with no sucess and no errors.
Isn't it possible to add an ajax function inside a jquery bind method or is it something else I'm doing wrong?
$('#ids').bind('click',function(event){
var str ="#" + event.target.id;
var subs=str.substring(2,str.length);
selectedWeapon="#E" + subs;
var mWeapon=$(selectedWeapon).text();
if(mWeapon=="Attack!")
{
indexInfo=selectedWeapon.indexOf('_');
if(indexInfo>0)
{
var res = "#" + selectedWeapon.substring(1,indexInfo) + "_VALS";
var resQT = "#" + selectedWeapon.substring(1,indexInfo) + "_NumberToSend";
selectedWeapon=$(res ).val();
selectedQuantity=$(resQT).val();
if(EnemyInfo!="")
{
$('#txtAttackInfo').val(selectedWeapon);
var tmp="";
var ReturnValue1=40;
// Obtain selected Object ID
$.ajax({
type: 'POST',
url: 'returnObjectID.php',
data: 'Name=' + selectedWeapon,
cache: false,
success: function(result) {
ReturnValue1=43;
if(result){
ReturnValue1=22;//result;
}
else
{
ReturnValue1=-1;
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("Status: " + textStatus);
alert("Error: " + errorThrown);
ReturnValue1=-4;
}
});
tmp="Attacking Player: " + EnemyInfo;
$("#divAtackInfo").html(tmp);
alert("Sending " + selectedQuantity + " " + selectedWeapon + " to " + EnemyInfo + " With returned id:" + ReturnValue1);
}
}
$('#txtAttackInfo').val(selectedWeapon);
}
});
My thanks in advanced