javascript - AJAX Post response data does not write to DOM with $('input').val() -
i have bizarre behavior going on ajax response.
on php page, have:
echo $items = $_post["items"];
and ajax function:
$j('.share-pdf').on('click', function () { var $body = $('body'); $body.addclass('loading'); var pullsheetname = "pullsheet-backbone", pullsheet = localstorage.getitem(pullsheetname); $.ajax({ cache: false, data: { items: pullsheet }, url: '/create-pdf?store=true', type: 'post', success: function (data) { alert(data); $body.removeclass('loading'); $('#share-url input').val(data).select(); $('#share-url').addclass('shared') } }); return false; });
while alert(data)
alerts data has been posted, nothing appears in input, $('#share-url input').val(data).select();
supposed do.
what doing wrong here , why isn't val()
writing data correctly specified input?
try little colon:
$('#share-url:input').val(data).select();
your
$('#share-url input').val(data).select();
means: in jquery find inputs inside of such as:
$('#share-url').find('input').val(data).select();
which ancestor/descendant form of selector re: $('div span')
- find spans in divs
Comments
Post a Comment