Home > front end >  Good code, suddenly can't use, don't know what happened
Good code, suddenly can't use, don't know what happened

Time:02-05

All function is normal, before one day in 2020, all of a sudden have a problem, what also did not move, which seems to be the first time the browser after upgrading, not line, a very strange thing,
Put the code, a great god, please advice, thank you very much!
Var Wparent=window. The parent. The document,
TipBg="& lt; Div class='tip_bg & gt;
" ,
TipBox="& lt; Div class='tip_box & gt;
" ,

//=====close the pop-up window
The function Tipclose () {
$(", Wparent tip_box "). The remove ();//remove the outer layer of the new className
$(", Wparent tip_bg "). The remove ();//remove the background of the new className
}
//=====submit data and change the popup window content
$(" submit "). Click (function () {
Var link=opts linkHref,
That=$(this);
If (validform (). The form ()) {
That prop (" disabled ", "disabled");
$. Ajax ({
Type: "post",
Url: opts formUrl,
Data: $(opts formId). Serialize (),
Success: the function (MSG) {
Var successTxt="& lt; P class='del_info & gt; Operation is successful & lt;/p>
";
Tipclose ();
$(" body ", Wparent). Append (tipBg);
$(" body ", Wparent). Append (tipBox);
$(". Tip_box ", Wparent). Append (successTxt);
Success (link);
That. RemoveAttr (" disabled ");
},
Error: function (errormsg) {
Var errorTxt="& lt; P class='del_info & gt; Operation failed, please retry & lt;/p>
";
Tipclose ();
$(" body ", Wparent). Append (tipBg);
$(" body ", Wparent). Append (tipBox);
$(". Tip_box ", Wparent). Append (errorTxt);
Success ();
That. RemoveAttr (" disabled ");
}
});
} else {
//check is not passed, what all need not do, check information has been correctly on the form
}
});


//=====success tip
The function Success (obj) {
$(" tip_box: last ", Wparent). The CSS ({" width ":" 400 px ", "height" : "180 px", "margin - top" : "90 px", "margin - left" : "200 px", "z - index" : "198611060"});
$(", Wparent tip_close ") on (" click ", function () {
Tipclose ();
If (obj!=null | | obj! Undefined)={
$(" body ", Wparent). Find (" iframe "), prop (" SRC ", obj);
} else {
$(" body ", Wparent). Find (" iframe "), prop (" SRC ", $(" body ", Wparent). Find (" iframe "). Prop (" SRC "));
}
});
}

Problem in the Success of $(", Wparent tip_close ") on (" click ", function () this position, click on the button can't perform, which is point button did not respond, the DIV is dynamically generated, also don't know how to deal with specific,
Try to mend the code: $(", Wparent tip_box ") on (" click ", "tip_close", function (), not
And changed to: $(" body ", Wparent) on (" click ", "tip_close", function (), or not
Add: jquery - 2.2.1. Min. Js

CodePudding user response:

can only say that you play breakpoints, cleared slowly,

CodePudding user response:

Look here first:
//=====submit data and change the popup window content
$(" submit "). Click (function () {

Here is not submitted data, you first make sure is to perform here, and then on to here, the add click method to work
$(", Wparent tip_close ") on (" click ", function () {

CodePudding user response:

Encounter problems why not open the console and the console. The log to debug?

CodePudding user response:

Submit to submit no problem,
I now is to turn a page, use the iframe way to call out to a DIV inside, and then submit the iframe, after processing the data, then shut off, back to the parent page, if open the pages of this iframe alone, no problem, can normal execution, but in the framework of the parent page open, not, always can be normally closed, before the 2020 one time, all of a sudden not line,

CodePudding user response:

The reason I haven't got a clue, look at your code is not the problem of asynchronous binding,
May be the browser security policy? The reason,

Suggest refactor the code, "calls out in iframe way into a DIV" do a pop-up box, show hidden or newly built gate closed gate,
  • Related