"thinkphp" Reference js file function error, directly write function in HTML use is normal

Source: Internet
Author: User
Tags jquery library
I created a new custom.js file under Public/admin/js: [Code=javascriptfunction validateusername () {

Alert (' Yes ');
$.post (
"<{:u (' index/index/users/validateusername ')}>",
{username:$ ("#UserName"). Val ()},
function (returneddata,status) {
var result=returneddata;
if (result!=null) {
$ ("#info"). HTML ("+result+");
}else{
$ ("#info"). HTML ("");
}
}
);

}][/code]
There is only one function, which is quoted in HTML:

Then use

Each call, the dialog box will appear, close the dialog box error:
Illegal operation:





Wrong location



file:c:\wamp\www\dianzi\thinkphp\common\functions.php line:112

The function of line 112 is this sentence:
function _404 ($msg = ', $url = ') {    app_debug && throw_exception ($msg);


The dialog box will pop out, do not know what the reason, and then I put this JS file reference deleted, the function is written directly in the HTML:

Can be used normally, how to solve this???


Reply to discussion (solution)

You did not introduce this problem due to the introduction of the jquery library file.

Ask is which library file, jquery.js this already had, and the popup window came out the explanation already called this function, is $.post also want other file?

You did not introduce this problem due to the introduction of the jquery library file.


Ask is which library file, jquery.js this already had, and the popup window came out the explanation already called this function, is $.post also want other file?

JS placed in the file, is not the background of this method did not find: U (' Index/index/users/validateusername '), and then the background directly error

JS in this "<{:u (' index/index/users/validateusername ')}>" There is a problem oh, you this is the external introduction, TP does not seem to be a template replacement for this

The U method is not allowed to be placed directly here. I remember when I learned TP video, the teacher in the video talked about the problem. It seems like you're going to use a variable to save the URL, and then pass it over. I don't remember it.

URL to be written in the template in order to correctly parse into a routing address

  • Related Article

    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.