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?


            var str ="#" + event.target.id;
            var subs=str.substring(2,str.length);
                        selectedWeapon="#E" + subs;
                        var mWeapon=$(selectedWeapon).text();


                                var res = "#" + selectedWeapon.substring(1,indexInfo) + "_VALS";
                                var resQT = "#" + selectedWeapon.substring(1,indexInfo) +  "_NumberToSend";

                                selectedWeapon=$(res ).val();

                                        var tmp="";
                                        var ReturnValue1=40;

                                        // Obtain selected Object ID
                            type: 'POST',
                            url: 'returnObjectID.php',
                            data:  'Name=' + selectedWeapon,
                            cache: false,
                            success: function(result) {

                                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                    alert("Status: " + textStatus); 
                                    alert("Error: " + errorThrown);


                        tmp="Attacking Player: " + EnemyInfo;
                        alert("Sending " + selectedQuantity + " " + selectedWeapon + " to " + EnemyInfo + " With returned id:" + ReturnValue1); 





My thanks in advanced

It is definitely possible to use $.ajax() within another jQuery function. I'm not sure what the issue is, but it is not that.

One problem you are going to have once you do get the AJAX working is that you are potentially using the variable ReturnValue1 before it has been set. It won't be set until the AJAX call completes. However, the code after your $.ajax() call will begin running immediately, so it's likely the code will reach your alert() before ReturnValue1 has been set.

Anyway, going back to your current problem, what does the alert() at line 54 produce? Does it even fire at all? Are you certain that the if (EnemyInfo != "") condition is true? Have you checked your Network tab of your developer tools (F12) in whatever browser you're using. This will let you see if the browser is making a call to returnObjectID.php at all or not.