IC SunsetThe developerWorks Connections platform will be sunset on December 31, 2019. On January 1, 2020, this community and its apps will no longer be available. More details available on our FAQ.
  • No replies
1 Post

Pinned topic innerhtml does not work with ajax

‏2011-04-12T22:09:26Z |
hi there
i have a scenario where i am trying to read the value within a div in a html page and pass that value to a server via ajax:

var formname = document.getElementById('username').innerHTML;

type: "POST",
url: "postForm.ajax.php",
dataType: "json",

success: function(msg)
//do stuff



however it seems as though the dom is generated before the html stuff is complete therefore the variable formname contains null and not "paulSm". Is there any way around this problem?
Any help you can give me would greatly be appreciated