792699d7c080a26288f50741fbfeca218d3ef2b5
larrym
  Wed Feb 9 10:02:10 2011 -0800
use return json for codonToPos and exonToPos
diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js
index 0145004..61fd5cc 100644
--- src/hg/js/hgTracks.js
+++ src/hg/js/hgTracks.js
@@ -1552,49 +1552,46 @@
                         $.ajax({
                                    type: "GET",
                                    url: "../cgi-bin/hgTracks",
                                    data: "hgt.trackImgOnly=1&hgt.ideogramToo=1&position=" + newPosition + "&hgsid=" + getHgsid(),
                                    dataType: "html",
                                    trueSuccess: handleUpdateTrackMap,
                                    success: catchErrorOrDispatch,
                                    error: errorHandler,
                                    cmd: cmd,
                                    cache: false
                                });
                     }
                 }
             }
     } else if (cmd == 'zoomCodon' || cmd == 'zoomExon') {
-        var num, ajaxCmd, errorMsg;
+        var num, ajaxCmd;
         if(cmd == 'zoomCodon') {
             num = prompt("Please enter the codon number to jump to:");
             ajaxCmd = 'codonToPos';
-            errorMsg = num + " is an invalid codon for this gene";
         } else {
             num = prompt("Please enter the exon number to jump to:");
             ajaxCmd = 'exonToPos';
-            errorMsg = num + " is an invalid exon number for this gene";
         }
         if(num) {
             $.ajax({
                        type: "GET",
                        url: "../cgi-bin/hgApi",
                        data: "db=" + getDb() +  "&cmd=" + ajaxCmd + "&num=" + num + "&table=" + args.table + "&name=" + args.name,
                        trueSuccess: handleZoomCodon,
                        success: catchErrorOrDispatch,
                        error: errorHandler,
-                       errorMsg: errorMsg,
                        cache: true
                    });
         }
     } else if (cmd == 'hgTrackUi_popup') {
 
         hgTrackUiPopUp( selectedMenuItem.id, false );  // Launches the popup but shields the ajax with a waitOnFunction
 
     } else if (cmd == 'hgTrackUi_follow') {
 
         var url = "hgTrackUi?hgsid=" + getHgsid() + "&g=";
         var rec = trackDbJson[id];
         if (tdbHasParent(rec) && tdbIsLeaf(rec))
             url += rec.parentTrack
         else {
             var link = $( 'td#td_btn_'+ selectedMenuItem.id ).children('a'); // The button already has the ref
@@ -2816,26 +2813,26 @@
         rec.localVisibility = visibility;
     }
     return selectUpdated;
 }
 
 function reloadFloatingItem()
 {
 // currently dead (experimental code)
     if(floatingMenuItem) {
         $('#img_data_' + floatingMenuItem).parent().makeFloat({x:"current",y:"current", speed: 'fast', alwaysVisible: true, alwaysTop: true});
     }
 }
 
 function handleZoomCodon(response, status)
 {
-    // XXXX use formal json interface
-    if(response.length > 1) {
-        setPosition(response, 3);
+    var json = eval("(" + response + ")");
+    if(json.pos) {
+        setPosition(json.pos, 3);
         if(document.TrackForm)
             document.TrackForm.submit();
         else
             document.TrackHeaderForm.submit();
     } else {
-        alert(this.errorMsg);
+        alert(json.error);
     }
 }