I'm having an issue where I cannot seem to pass the variable "notes" into the placeholder of a form. More Info Below Code:
request.done(function(data) {
window.notes = data;
//document.write(notes);
});
request.fail(function() {
// document.write("fail");
});
$(document).ready(function(){
$('form').find("textarea").each(function(ev)
{
if(!$(this).val()) {
// document.write(notes); Says undefined?
$(this).attr("placeholder",window.notes);
}
});
});
The placeholder code works...if I use
$(this).attr("placeholder","test");
It works without problem as it should, but it will not if I try to use the var notes.
The setting of var notes works as well. If I uncomment the document.write("notes") I get the value I expect.
I have tried:
I originally started with Var notes = data; but moved to window.notes based on a suggestion by another question to make it global. Did not work. I also tried "forcing" the variable to be global by setting outside the function scope empty, but that didn't work either.. Is there something I'm missing?
Thanks!