Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Yes, you can trigger ajax calls on drop. <a href="http://jsbin.com/idopo3" rel="nofollow">(live example)</a></p> <p>I see a couple of issues (details below):</p> <pre><code>$("div.square").droppable({ accept: '.white', drop: function (event, ui) { $to = "#" + $(this).attr('id');// &lt;== 1. Implicit Global? alert(to); // &lt;== 2. Syntax error $.post( "/Game/AddMove", { from: $from, // &lt;== 3. Where does this come from? to: $to, GameID: $("#gameID").val() }); } }); </code></pre> <ol> <li>You seem to be using <code>$to</code> without declaring it. (If it's declared in a containing scope you haven't shown, that's fine; otherwise, though, you're falling prey to the <a href="http://blog.niftysnippets.org/2008/03/horror-of-implicit-globals.html" rel="nofollow">Horror of Implicit Globals</a>. (That's probably not what's keeping it from working, though.)</li> <li>The code should blow up here, unless <code>to</code> is defined somewhere. You don't have any variable called <code>to</code>.</li> <li>You're using a variable <code>$from</code> that isn't defined in your quoted code. Fair 'nuff if it's defined in an enclosing scope, but if so, probably worth mentioning in the question.</li> </ol> <p>If none of the above is it, just walk through the code. There are plenty of browser-based debuggers these days. If you use Firefox, install and use Firebug. If you use Chrome or Safari, they have Dev Tools built in (you may have to enable them in preferences). If you use IE, IE8 and up have a built-in debugger; for IE7 and earlier you can use the free version of VS.Net. For Opera, it has a built-in debugger called Dragonfly... In all of these, you can set a breakpoint on the first line of your <code>drop</code> handler and step through to see what's going wrong.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload