Changing javascript to jQuery first time Struts 1.3 application -
i changing javascript in project jquery. first time im using jquery , expect me making silly mistakes please. placed simple jq alert function in .js file looks below.
$(document).ready(function(){ $("#stt").change(function(){ alert("hi"); }); });
so aim throw alert msg when value of td element id="stt" changed.
<tr id="stttr"> <td id="stt"> <html:text property="stt" size="20" maxlength="20" style="height:12px; width: 180px;" /></td></tr>
and how im referencing jquery between head tags of jsp.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9/jquery.min.js"></script> <script src="javascript/searchpaneljq.js"></script> <script src="javascript/calendarpopup.js"></script>
the calendarpop.js older javascript file dont want replace (it works fine on browsers). when visit page in browser script debugging enabled in ie, following error .
html1201: localhost website you've added compatibility view. reportingtemplate.jsp sec7115: :visited , :link styles can differ color. styles not applied :visited. reportingtemplate.jsp script5007: value of property '$' null or undefined, not function object searchpaneljq.js, line 1 character 1
the last line tells me not right setup. can tell me what?
i installed jsdt jquery plugin , using jq v1.9. project struts project.
edit: 1) works when jq function included in jsp. dosent work when in different .js file. 2) if include http:in reference, works when document.ready function in same jsp , not when in different .js file. beats purpose same validations used in multiple pages in project.
for future reference:
run in chrome (or browser other users have pointed out)
right click > inspect element > console
read error logs (console can provide js, php, , other errors pinpoint specific lines malfunction happening)
your
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9/jquery.min.js"></script>
should be
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9/jquery.min.js"></script>
the reason, provided user2736012 is:
op using "protocol relative" url, automatically uses protocol used fetching page. in case, if protocol file://home/user/desktop/foo.html
, protocol relative url becomes file://ajax.googlapis...
, of course won't work. it'll work when fetching page using http, because it'll http://ajax.googleapis...
Comments
Post a Comment