0

I have made my ajax request, which works great and get response with type POST(server side is PHP). now i want to use it in the placeholder of an element with this code

function checkAvailability() {
    $("#loaderIcon").show();
    jQuery.ajax({
        url: "<?php echo ADDR;?>inc/promotion_check_availability.php",
        data:'code='+$("#code").val(),
        type: "POST",
        success:function(data){
            $("#result").html(data);
            var result = $(data).filter('#result');
            $("#amount").attr("placeholder", result);
            $("#loaderIcon").hide();
        },
        error:function (){}
    });
};

but in the placeholder of an element shown [object Object]. i don't know what is the problem. i really appreciate if some one help me figuring out this problem.

Ash
  • 2,108
  • 2
  • 17
  • 22
masih
  • 47
  • 8

2 Answers2

0

try $("#amount").attr("placeholder", result.html()); or $("#amount").attr("placeholder", result.text());

madalinivascu
  • 32,064
  • 4
  • 39
  • 55
0

thanks to answer my question. i search a lot in the stackoverflow and find this answer and work for me:

JQuery - Storing ajax response into global variable

Community
  • 1
  • 1
masih
  • 47
  • 8