jquery - code on jsfiddle vs active server (code on active server isn't working correctly) -


here problem, put piece of code in jsfiddle, , works perfectly. put same code on website, adding in header include jquery , jquery ui (links directly jquery sites, not hosting files locally) , code doesn't work.

i attempting "sortable" effect work in project. not code either. been every single piece of code has draggable, movable, etc. uses jquery. i'm missing , can't think of is.

i own servers in datacenter, , running cpanel, have full access server if need make changes.

when test code on jsfiddle, when click , drag

  • tags, doesn't highlight text , moves <li> tags allowing me reorder list. on website, starts highlighting text , doesn't move file. html same on both places.

    any ideas?

    jsfiddle : http://jsfiddle.net/ygrup/

    code: (some of code still there interacts php code; however, removed php code example testing)

    <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>untitled document</title> <script src="http://code.jquery.com/jquery-1.10.1.js"></script> <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> <script type="text/javascript"> <script type="text/javascript"> /* when dom ready */ jquery(document).ready(function() {     /* grab important elements */     var sortinput = jquery('#sort_order');     var submit = jquery('#autosubmit');     var messagebox = jquery('#message-box');     var list = jquery('#sortable-list');     /* create requesting function avoid duplicate code */     var request = function() {         jquery.ajax({             beforesend: function() {                 messagebox.text('updating sort order in database.');             },             complete: function() {                 messagebox.text('database has been updated.');             },             data: 'sort_order=' + sortinput[0].value + '&ajax=' + submit[0].checked + '&do_submit=1&byajax=1', //need [0]?             type: 'post',             url: '<?php echo $_server["request_uri"]; ?>'         });     };     /* worker function */     var fnsubmit = function(save) {         var sortorder = [];         list.children('li').each(function(){             sortorder.push(jquery(this).data('id'));         });         sortinput.val(sortorder.join(','));         console.log(sortinput.val());         if(save) {             request();         }     };     /* store values */     list.children('li').each(function() {         var li = jquery(this);         li.data('id',li.attr('title')).attr('title','');     });     /* sortables */     list.sortable({         opacity: 0.7,         update: function() {             fnsubmit(submit[0].checked);         }     });     list.disableselection();     /* ajax form submission */     jquery('#dd-form').bind('submit',function(e) {         if(e) e.preventdefault();         fnsubmit(true);     }); }); </script> <link rel="stylesheet" type="text/css" href="css/style.css"/> </head>  <body>  <ul id="sortable-list"> <li title="1">item 1</li> <li title="2">item 2</li> <li title="3">item 3</li> <li title="4">item 4</li> </ul> 

  • you have two opening script tags:

    <script type="text/javascript"> <script type="text/javascript"> /* when dom ready */ jquery(document).ready(function() { 

    the second 1 treated javascript code, , fails parse. should getting error in dev tools console; instance, chrome says uncaught syntaxerror: unexpected token <

    to fix it, remove 1 of them. (it works on jsfiddle because didn't paste script tags in.)


    Comments

    Popular posts from this blog

    java.util.scanner - How to read and add only numbers to array from a text file -

    rewrite - Trouble with Wordpress multiple custom querystrings -