javascript - Showing Credit Card Brand Within TextField with JQuery -


i have input text field credit card number. i'd change image background whenever credit card number inserted. goal show credit card brand within it.

the code i've been working on is:

function get_brand_image(){   $.ajax({     url: '/cards',     type: "post",     datatype: "json",     data: {code: $("#card_brand").val()},     error: function(response){      },     success: function(response){       $('#card_brand').css({background: "'url("+response['path']+") 0 no-repeat'", 'background-position': 'right'})     }   });    } 

the above code doesn't add background image text although second hash parameter ('background-position': 'right') is.

what's strange if put raw comand:

$('#card_brand').css({background: 'url(/assets/cards/visa.png) 0 no-repeat', 'background-position': 'right'}) 

everything done it's supposed to.

am incurring in mistake when concatenating strings?

any appreciated.

$('#card_brand').css({background: 'url('+response['path']+') 0 no-repeat', 'background-position': 'right'}); 

try this. supposing haven't mixed 'id's.

also:

alert(response['path']); 

and make sure it's correct link.

here working jsfiddle:

http://jsfiddle.net/grimbode/9trhw/1/


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -