1

I am storing the response recieved by ajax call in the following way but it is not working. Am I doing something wrong?

var res;
function add(thelink)
{
    var id = thelink;

    $.ajax({
        type:"POST",
        url:"addtocartAjax",
        data:"id="+id,

        success: function(response){
               res=response;
               $('#ajaxbox').html(" "); 
               $("#ajaxbox").append("<center id='mid' class='switch longbutton'>\n\
                  "+ response + "</center>"); 

        }           

    });

    document.write(res);
}    
palak sharma
  • 231
  • 1
  • 12

0 Answers0