jQuery Validation not working in server! Works Locally. Why?

青春壹個敷衍的年華 提交于 2019-12-12 09:53:59

问题


When I tried jQuery validation locally it works fine. But when I upload to my server the validation is not working. The page just simply reloads. Why is it so?

Here is the fiddle.

http://jsfiddle.net/anish/Q9qes/3/


回答1:


In your JSFiddle, under Manage Resources, your link to the jQuery Validation plugin is giving a 404 error. Maybe that's why it's not working on your server.

EDIT:

There is no such tag as </input>. Remove those.

Perhaps run your HTML & CSS through a validator.

Also, the version of your jQuery Validation plugin is not up to date with your jQuery version.




回答2:


well jquery is a client side library which runs on browser. it doesnt have relation with what server you are using. if your jquery is having some connection with serverside files, then there is a problem in definitions of URLs in your jquery files. please recheck all the URLs again in your jquery files. Specially in those functions in which you are using Jquery AjaX




回答3:


The your page works locally is because your page is correctly linked to your jquery library (am guessing is in a folder called js/jquery.min.js), however remotely the js folderdoesn't contain the jQuery.min.js library in the folder.

Solution one: You can either ensure that the jQuery.min.js library actually exists on your remote server or...

Solution two (which is a better one): Let Google host JQuery for you. by changing the below from: enter code here<script type="text/javascript" src="/js/jQuery.min.js"></script> to: <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"> . This will enable it to work both remotely and locally. Doing this also has other upsides you might find advantageous.

check out: http://encosia.com/3-reasons-why-you-should-let-google-host-jquery-for-you/

I hope this helps

Reference:

Dave Ward, 2011. 3 reasons why you should let Google host jQuery for you. [online] Available at: http://encosia.com/3-reasons-why-you-should-let-google-host-jquery-for-you/ [Accessed 24 MArch 2012 ].



来源:https://stackoverflow.com/questions/6223065/jquery-validation-not-working-in-server-works-locally-why

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!