Sanjay Yadav Sanjay Yadav - 3 months ago 6
Javascript Question

how i can send a confirmation response to my API , when user click on activation link

I am trying to send a confirmation message to my API after click on activation link , I am trying lot but failed ,
http://polestarllp.com/users/useractive.php?contranumberid=23215

<script type="text/javascript">
$(document).ready(function () {
$("a[href$='.contranumber']").click(function () {

debugger;
$.ajax({
url: 'http://192.168.1.102:1512/qlikapi/RegisterUser',
type: 'Post',
success: function (data, textStatus, xhr) {
alert(data.ErrorMessage);
if(data.Success)
{
document.location.reload();
}

},
error: function (xhr, textStatus, errorThrown) {
console.log('Error in Operation');
}
});


});
});
</script>

Answer

The script you have given in the question and the actual script in the page linked in question is slightly different. The success callback function was missing closing braces. Here's a better version of your JS code:

<script type="text/javascript">
    function myfunc(id) {
        id = 23215;
            $.ajax({        
                url: 'http://192.168.1.102:1512/qlikapi/RegisterUser',
                type: 'post',             
                data: {'id' : 23215},
                success: function (data, textStatus, xhr) {
                    alert(data.ErrorMessage);   
               }        
           });
     }
</script>

Also, I didn't see any code invoking myfunc() anywhere?

Comments