Set html attribute via ajax
OK I got this script doing everything it needs to do. My PHP function in wordpress is sending the correct AJAX response.
So why, after nearly 3 hours, can I STILL not set the link's href attribute? I have tried every combination I can think of to get the response into the <a title=""> attribute, but no dice.
the <a> does not have a title initially, BTW
I've tried this. Even this forum is screwing with me. Next metod tried in reply.
- jQuery( document ).ready( function( $ ) {
- $( 'body p.single-quot a.single-quot' ).prop( 'title', function() {
jQuery.ajax({
url: ajaxUrl,
type: 'post',
data: {
action: 'doghaus_get_title',
href: $( this ).prop( 'href' )
},
dataType: 'JSON',
success: function( response ) {
return response
},
error: function( errorThrown ) {
console.log( errorThrown )
}
})
-
})
- })