JS Code Small optimization

Source: Internet
Author: User

Today really pit, the eldest brother asked for two days off, came after pointing point, but others said is very in place

Finally the nested small window login registration function, finished, direct adjustment before writing a login registration function, that is, page jump

Not Ajax asynchronous landing

Say let's change to Ajax and return to JSON format. That means using @responsebody.

Well, yes, change it, the page directly with the Freemarker value is also a problem, after all, Ajax background model,put (), the value is not taken out.

After all, the Login registration window is a extracted HTML, the page needs to be directly included in it.

Ok. I feel very comprehensive about myself, and I wrote a dead callback after Ajax success.

Smart too much, boss a look, say you write this is not perfect, also need to optimize under.

What the hell is that?

The callback method was written dead. Need to be flexible.

Well, yes, the final solution is to write a custom attribute in <body> data-seo= "FFF"

After the success inside the var Varf = $ ("body"). Data ("SEO");

Eval (varf+ "()") to make a dynamic call. The default implementation is

window.location.reload () //page Refresh ...

Modifications can be made based on the source code without affecting it. Or just add ... ()
Place


$ ("#id"). Trigger ("click");
How to Trigger V-on:click
$("#id")[0].dispatchEvent(new Event(‘click‘));恩,获取到对象之后触发。
奋斗吧骚年。。。

JS Code Small optimization

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.