0

I am loading another html page from an index page, then I would like to get an element from that loaded page, but the page seems not loaded yet since the element resulted to null, even if there is a function call back with in the ajax load function:

$(document).ready(function() {

$('#btnEdit').click(function(){


    $('#contents').load("abcd.html",showNewcontents())


    function showNewcontents() {

        alert("" + document.getElementById("make").value);
    }

return false;

});

});

in body:

<body>

<a href="click me" id="btnEdit" name="btnEdit">CLICK ME </a>

<div id="contents"></div>

</body>

in abcd.html:

<div id="contents">


<form> 

<input type="hidden" id="make" name="make" value="make">

</form>


</div>

Any clue as to how to modify this to get the element?

1 Answer 1

2

load expects to receive a function as an argument.

showNewcontents() calls a function.

You are passing the return value of the call to showNewcontents, not the showNewcontents function.

Remove the ().

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.