Search code examples
javascriptjqueryhtmlobjective-cios6

how to include jquery library in Xcode project?


I have a UIWebView which loads local .html files from resource bundle. everything is working fine except that the Javascript code written inside .html file is not working at all. I don't have .js file to show popup view in .html file. instead of it the JS code is written inside .html file.

here are some screen shots of my xcodeproject :-

enter image description here

enter image description here

by looking around over google all i could gather was that, since i am not using network connection inside my app at all,(i am loading everything locally ) the src for jQuery Library isn't being downloaded.

so is there something which can replace following line in .html file

" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">"

Or Am i going with the wrong approach ??

EDIT

if this helps :-

i have also tried opening those .html files in safari inside my MAC.. . . JS code didn't work there too.

well . . .

am i trying to accomplish something impossible here ?... :D


Solution

  • You need to download jquery locally and point to your local jquery file into <script> tag

    e.g : local jquery path

    /my_local_folder/js/jquery/jquery.min.js
    

    Changing

    <script src="ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
    

    Width the local jquery file

    <script src="my_local_folder/js/jquery/jquery.min.js">