js code :
function pTest () {
var url = "child.jsp";
$ ("# mainFrame"). attr ("src", url);
var msg = document.mainFrame.resultStr ;/ / this is to get a js subpages string variable
}
html:
subpages as follows:
body has a
initDeptData () {
$. ajax ({
type: "POST",
url: url,
data: "", / / submit the entire form
success: function (msg) {
/ / there is return a string through the business process
resultStr = msg;
},
error: function () {
alert (' Error initializing sector information ! ' ) ;
}
});
}
questions are as follows , I want to get the parent page document.mainFrame.resultStr, but there is a problem, because subpages initDeptData () This method will consume some time, I now want when resultStr = msg ; to return immediately when this msg to acquire document.mainFrame.resultStr, how to do ? ? ?
I am now using setTimeout, but this is not insurance , it may result in a waste of time
solved ....
------ Solution ------------------------------------ --------
You can call the parent page subpages js method, and then put the string passed over. Should be. . .
------ Solution ---------------------------------------- ----
subpages parent page in variable assignment
------ Solution ------------------------- -------------------
example, you define subpages
<script>
var zipphone = "<?= $phone ?>";
</script>
parent page you can define such a method values:
function zipPhoneCallback(zipphone) {
((console&&console.log)||alert)("zipphone = " + zipphone);
} Then subpages pass this value:
window.parent.zipPhoneCallback(zipphone);
------ For reference only ----------------------------------- ----
moment did not turn around , you're on it ....
------ For reference only ------------------- --------------------
and second floor almost, thank
------ For reference only --------------------------- ------------
has been resolved, with Frank
没有评论:
发表评论