Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>this is why you shouldn't hardcode urls in an asp.net mvc app. your problem is that your ajax url is a relative url. when you load the page using url <a href="http://example.com/TestInput/" rel="nofollow">http://example.com/TestInput/</a> the ajax url ends up being something like <a href="http://example.com/TestInput/TestInput/listTestCases" rel="nofollow">http://example.com/TestInput/TestInput/listTestCases</a> or maybe <a href="http://example.com/TestInput/listTestCases" rel="nofollow">http://example.com/TestInput/listTestCases</a></p> <p>When you use the url <a href="http://example.com/TestInput/Index" rel="nofollow">http://example.com/TestInput/Index</a> your ajax url ends up being <a href="http://example.com/TestInput/Index/TestInput/listTestCases" rel="nofollow">http://example.com/TestInput/Index/TestInput/listTestCases</a></p> <p>Insetead you should use one of the Html helpers to declare your ajax url like this. (using razor syntax)</p> <pre><code>&lt;script&gt; $(document).ready(function() { $('select#testCategoriesUniqueId').change(function() { var testCategory = $(this).val(); $.ajaxSetup({ cache: false }); alert ("AAA"); $.ajax({ url: "@Url.Action("listTestCases")"+ "/" + testCategory, dataType: "json", type: 'post', success: function(data) { $("#testCasesUniqueId").removeOption(/./); for (var i = 0; i &lt; data.length; i++) { var val = data[i].Value; var text = data[i].Text; $("#testCasesUniqueId").addOption(val, text, false); } } }); }); }); &lt;/script&gt; </code></pre> <p><strong>Update for ASPX View Engine:</strong></p> <p>If you are using the ASPX view engine insted of Razor use this syntax.</p> <pre><code>&lt;script&gt; $(document).ready(function() { $('select#testCategoriesUniqueId').change(function() { var testCategory = $(this).val(); $.ajaxSetup({ cache: false }); alert ("AAA"); $.ajax({ url: "&lt;%=Url.Action("listTestCases")%&gt;"+ "/" + testCategory, dataType: "json", type: 'post', success: function(data) { $("#testCasesUniqueId").removeOption(/./); for (var i = 0; i &lt; data.length; i++) { var val = data[i].Value; var text = data[i].Text; $("#testCasesUniqueId").addOption(val, text, false); } } }); }); }); &lt;/script&gt; </code></pre> <p>Be sure to use Firebug or F12 dev tools to double check the exact url you need.</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