gpt4 book ai didi

c# - ASP.NET MVC DropDownList 导致我不期望的回发 - 似乎源自 JavaScript

转载 作者:行者123 更新时间:2023-12-03 11:48:31 27 4
gpt4 key购买 nike

我的 MVC 项目中有一个标准表单,其中有一个 DropDownList。当我更改下拉列表的值时,整个页面会重新加载,因为它会导致回发。

我不希望出现这种行为,并且我正在尝试停止下拉列表以进行回发。

然而,这就是奇怪的地方。我通过以下方式定义我的下拉列表:

@Html.DropDownList("sortOrder", null, new { onchange = "startUpdate(this)" })

忽略 Javascipt,没有什么会期望我进行回发。如果我们包含整个表单,我们可以看到这里也是如此:

 @using (var form = Html.BeginForm("Query", "Search", FormMethod.Get, new { id="queryform", name="queryform", onsubmit = "startUpdate(this); return false;"}))
{

<b>Sorter efter</b><br />
@Html.DropDownList("sortOrder", null, new { onchange = "startUpdate(this)" })<br />
</div>
<br />
<input type="submit" class="button_green" value="Søg igen &#x25BA;" id="SearchButton" name="SearchButton" style="float: left;" onclick="_gaq.push(['_trackEvent', 'Ads_listing', 'search_again_click']); startUpdate(this); return false;" />
<input type="reset" class="button_small" value="Nulstil" id="ClearButton" style="float: right;" />
</text>
}

但是,现在聪明人可能会说:

"try to disable JavaScript, and see what happens"

所以我就这么做了。然后回发没有发生。所以我的问题很可能源自某些 JavaScript。

唯一的问题?我好像找不到。

我已经清除了我能想象到的所有与它有关的 JavaScript,但它仍然给我一个回发。

所以,抱歉,我必须包含所有渲染的标记,希望你们能帮助我解决这个大问题(选择的 html 元素称为 sortOrder):

(我无法复制整个 HTML,因此我删除了一些部分 - 可以在 http://www.amino.dk/virksomhedsbors/search/query?transactionType=2&text=&sectorList=&priceFrom=&priceTo= 中看到生产版本)

<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang=&quot;da-dk&quot;>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Virksomheder til salg</title>
<script type="text/javascript">var _sf_startpt = (new Date()).getTime()</script>
<link href="/styles/saxis.min.css?v=1" rel="Stylesheet" type="text/css" />

<link target="_blank" href="http://fonts.googleapis.com/css?family=Lato:300,400,700,900" rel="stylesheet" type="text/css">
<link href="http://www.amino.dk/virksomhedsbors/rss.aspx" rel="alternate" title="Virksomheder købes og sælges" type="application/rss+xml" />
<link href="http://www.amino.dk/virksomhedsbors/rss.aspx?type=buy" rel="alternate" title="Virksomheder købes" type="application/rss+xml" />
<link href="http://www.amino.dk/virksomhedsbors/rss.aspx?type=sell" rel="alternate" title="Virksomheder til salg" type="application/rss+xml" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.js"></script>

<script type="text/javascript" src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>

<script type="text/javascript" src="http://eas4.emediate.eu/EAS_tag.1.0.js"></script>

<script type="text/javascript" src="/Assets/js/global.js?2.0"></script>

<script type="text/javascript" src="/user/infobox?635467592356980146"></script>



<script type="text/javascript">
$(document).ready(function () {
$.ajaxSetup(
{ cache: false }
);
}
);
</script>
<style type="text/css">
<!--
.cell {
padding-left: 15px;
}
-->
</style>
<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-10494982-1']);
_gaq.push(['_setDomainName', '.amino.dk']);



_gaq.push(['_setCustomVar', 1, 'Medlemstype', 'Ikke registreret', 1]);
_gaq.push(['_setCustomVar', 2, 'VB-type', 'Ikke registreret', 1]);

document.referrer.match(/https?:\/\/[^/]*google\..*[?&]cd=([^&]*)/gi);
var gaqgr = RegExp.$1;
if (gaqgr) {
_gaq.push(['_setCustomVar', 3, 'GoogleRank', gaqgr, 2]);
}


_gaq.push(['_trackPageview']);



_gaq.push(['_trackPageLoadTime']);

(function () {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();



</script>
</head>
<body>
<div id="background_body">

<div id="topad" style="clear: both; text-align: center; margin: 0 auto 10px">
<div id="EAS_c13cb956" style="width:930px;height:180px;margin:0 auto;border:0;padding:0;"></div>
<script type="text/javascript">
$(document).ready(function() {
EAS_load_fif("EAS_c13cb956", "/EAS_fif.html", "http://eas4.emediate.eu/eas?cu=1202;cre=mu;js=y;target=_blank;ord=635467592356990147", 930, 180);
});
</script>

</div>

</div>
</div>
<div id="body">
<div id="contentBody">

<div id="sidead" style="position: fixed; width: 300px; height: 600px; margin-left: 963px; top:180px;">
<div id="EAS_5408e9fb" style="width:300px;height:600px;margin:0 auto 0 0;border:0;padding:0;"></div>
<script type="text/javascript">
$(document).ready(function() {
EAS_load_fif("EAS_5408e9fb", "/EAS_fif.html", "http://eas4.emediate.eu/eas?cu=13120;cre=mu;js=y;target=_blank;ord=635467592359750304", 300, 600);
});
</script>
</div>



<div id="UserInformation" style="display: none;"></div>




<div class="column left" style="width: 698px;">
<div class="contentBoxtitle2">
<span style="float: right; margin-right: 5px; margin-top: 5px;" id="SAAdd" class="SearchAgentButton"><a href="javascript:void(0);" onclick=" _gaq.push(['_trackEvent', 'Ads_listing', 'add_searchagent_click']); addSearchAgent(); ">Tilføj som søgeagent</a></span>
<h1 class="contentBoxtitle_home" style="width: 395px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden;" id="searchtitle">Virksomheder til salg</h1>
</div>
<div id="searchResults">


<div class="contentBoxSubtitle2">
<h2>
Viser <u>1</u> til <u>30</u> af i alt <u>1383</u>


<div style="float: right;">

<< Forrige
|
1 |
<a href="/search/query?transactiontype=2&amp;pagesize=30&amp;pageno=2&amp;sortorder=0">2</a>
|
<a href="/search/query?transactiontype=2&amp;pagesize=30&amp;pageno=3&amp;sortorder=0">3</a>
|
<a href="/search/query?transactiontype=2&amp;pagesize=30&amp;pageno=4&amp;sortorder=0">4</a>
|
<a href="/search/query?transactiontype=2&amp;pagesize=30&amp;pageno=5&amp;sortorder=0">5</a>
|
<a href="/search/query?transactiontype=2&amp;pagesize=30&amp;pageno=6&amp;sortorder=0">6</a>
|
<a href="/search/query?transactiontype=2&amp;pagesize=30&amp;pageno=7&amp;sortorder=0">7</a>
|
<a href="/search/query?transactiontype=2&amp;pagesize=30&amp;pageno=2&amp;sortorder=0">Næste &gt;&gt;</a>
&nbsp;




</div>
</h2>
</div>
<div class="contentBox2">

<script type="text/javascript">
var sortLink = "/search/query?transactionType=2&amp;text=&amp;priceFrom=&amp;priceTo=&amp;yearFrom=&amp;yearTo=&amp;saleReasons=&amp;canMove=&amp;regions=&amp;operatingRegions=&amp;allOperatingRegionsRequired=&amp;sectors=&amp;allSectorsRequired=&amp;financingAvailable=&amp;country=&amp;pageSize=30&amp;sortOrder={sortOrder}&amp;";
</script>

<div style="text-align: right; margin-bottom: 3px;">Sorter efter <select id="order" name="order" onchange="top.location.href=sortLink.replace(&quot;{sortOrder}&quot;, this.value); "><option selected="selected" value="0">Relevans</option>
<option value="1">Oprettelsesdato (nyeste f&#248;rst)</option>
<option value="2">Oprettelsesdato (&#230;ldste f&#248;rst)</option>
<option value="3">Redigeringsdato (nyeste f&#248;rst)</option>
<option value="4">Redigeringsdato (&#230;ldste f&#248;rst)</option>
<option value="5">Pris (h&#248;jeste f&#248;rst)</option>
<option value="6">Pris (laveste f&#248;rst)</option>
</select></div>

<div class="silverbox even" style="">
<div class="ribbon silver"></div>
<p class="adtitle">
<a href="/saelges/handel/agenturhandel/btb-og-btc-udklaedning-legetoej-og-kostumer-inkl-varelager-til-salg-19115">BtB og BtC Udklædning, legetøj og kostumer inkl varelager til salg</a>

<img src="/images/icon_unlock20x25.png" alt="Du kan kontakte denne annonce" style="width: 20px; height: 25px; border: none;" />
</p>
<p class="regions">Midtjylland</p>
<div class="price"><span class="pricelabel">Udbudspris:</span> <span class="pricevalue">895.000 DKK</span></div>
<div class="category"><span class="categorylabel">Forretningsområde:</span> <span class="categoryvalue">Agenturhandel</span></div>
<p class="description">Velkendt engros firma der handler med udklædning, kostumer og legetøj. Mange faste kunder spredt over hele landet giver en god stabil omsætning. Salget foregår via hjemmeside og kundebesøg<b>...</b></p>
<p class="seemore">
Se flere virksomheder til salg inden for:<br />
<a href="/saelges/handel/agenturhandel">Agenturhandel</a>

</p>
<p class="date" style="float: right; clear: both; text-align: right;">
Senest redigeret 16-09-2014
</p>
</div>
<br />
<br />

</div>

<div class="contentBoxSubtitle2">
<h2>
Viser <u>1</u> til <u>30</u> af i alt <u>1383</u>
<div style="float: right;">

<< Forrige
|
1 |
<a href="/search/query?transactiontype=2&amp;pagesize=30&amp;pageno=2&amp;sortorder=0">2</a>
|
<a href="/search/query?transactiontype=2&amp;pagesize=30&amp;pageno=3&amp;sortorder=0">3</a>
|
<a href="/search/query?transactiontype=2&amp;pagesize=30&amp;pageno=4&amp;sortorder=0">4</a>
|
<a href="/search/query?transactiontype=2&amp;pagesize=30&amp;pageno=5&amp;sortorder=0">5</a>
|
<a href="/search/query?transactiontype=2&amp;pagesize=30&amp;pageno=6&amp;sortorder=0">6</a>
|
<a href="/search/query?transactiontype=2&amp;pagesize=30&amp;pageno=7&amp;sortorder=0">7</a>
|
<a href="/search/query?transactiontype=2&amp;pagesize=30&amp;pageno=2&amp;sortorder=0">Næste &gt;&gt;</a>
&nbsp;




</div>
</h2>
</div>
</div>
<div class="contentBoxFooter2"></div>
</div>
<div class="column">
<div class="box">
<p class="title">Indskrænk/ændre søgning</p>
<div class="boxbody">

<form action="/search/query" id="queryform" method="get" name="queryform" onsubmit=" return false;">
Din rolle er:<br/>&nbsp;&nbsp; <input checked="checked" id="trsBuyer" name="transactionType" onclick="startUpdate(this)" type="radio" value="2" />&nbsp;<label for="trsBuyer">Køber</label>&nbsp;&nbsp;&nbsp; <input id="trsSeller" name="transactionType" onclick="startUpdate(this)" type="radio" value="1" />&nbsp;<label for="trsSeller">Sælger</label><br />
<br />
<b>Søgeord:</b><br />
<input id="text" name="text" onkeypress="startUpdate(this)" onkeyup="startUpdate(this)" style="width: 210px;" type="text" value="" /><br />
<br />
<b>Forretningsområder:</b><br />
<a href="javascript:void(0);" onclick=" $(this).hide(500); $('#secadv').show(500); ">Avanceret &#x25ba;</a><span id="secadv" style="display: none;"><input id="allSectorsRequired" name="allSectorsRequired" onclick=" " style="margin-top: 2px;" type="checkbox" value="true" /><input name="allSectorsRequired" type="hidden" value="false" /> <label for="allSectorsRequired">Alle er påkrævet (OG-søgning)</label></span>
<input type="checkbox" onclick=" " name="sectors" value="12" id="sector12" />
<label for="sector12"> Transportmiddelindustri</label></div>
</div>
</div>


<br />
<a id="showadvprops" href="javascript:void(0);" onclick=" _gaq.push(['_trackEvent', 'Ads_listing', 'search_advanced_criteria']); showAdvancedProps(); ">Vis avancerede kriterier &#x25ba;</a>
<a id="hideadvprops" href="javascript:void(0);" onclick=" showAdvancedProps(); " style="display: none;">Skjul avancerede kriterier &#x25c4;</a><br />
<br />
<div id="advsearch" style="display: none;">
<b>Beliggenhed:</b><br />
<div style="height: 100px; overflow: auto; border: 1px solid #999; padding: 1px 1px 1px 1px; margin-top: 2px;">

<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Nordjylland">
<input type="checkbox" name="regions" onclick=" " value="1" id="region1" />
<label for="region1"> Nordjylland</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Midtjylland">
<input type="checkbox" name="regions" onclick=" " value="2" id="region2" />
<label for="region2"> Midtjylland</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Syd- og S&#248;nderjylland">
<input type="checkbox" name="regions" onclick=" " value="3" id="region3" />
<label for="region3"> Syd- og S&#248;nderjylland</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Fyn">
<input type="checkbox" name="regions" onclick=" " value="4" id="region4" />
<label for="region4"> Fyn</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Sj&#230;lland, &#216;erne og Bornholm">
<input type="checkbox" name="regions" onclick=" " value="5" id="region5" />
<label for="region5"> Sj&#230;lland, &#216;erne og Bornholm</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Stork&#248;benhavn">
<input type="checkbox" name="regions" onclick=" " value="6" id="region6" />
<label for="region6"> Stork&#248;benhavn</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Ikke oplyst">
<input type="checkbox" name="regions" onclick=" " value="7" id="region7" />
<label for="region7"> Ikke oplyst</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Hele landet">
<input type="checkbox" name="regions" onclick=" " value="8" id="region8" />
<label for="region8"> Hele landet</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Udlandet">
<input type="checkbox" name="regions" onclick=" " value="9" id="region9" />
<label for="region9"> Udlandet</label></div>
</div>

<br />
<b>Opererer i:</b><br />
<a href="javascript:void(0);" onclick=" $(this).hide(500); $('#regadv').show(500); ">Avanceret &#x25ba;</a><span id="regadv" style="display: none;"><input id="allOperatingRegionsRequired" name="allOperatingRegionsRequired" onclick=" " style="margin-top: 2px;" type="checkbox" value="true" /><input name="allOperatingRegionsRequired" type="hidden" value="false" /> <label for="allOperatingRegionsRequired">Alle er påkrævet (OG-søgning)</label></span>
<div style="height: 100px; overflow: auto; border: 1px solid #999; padding: 1px 1px 1px 1px; margin-top: 2px;">
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Nordjylland">
<input type="checkbox" name="operatingRegions" onclick=" " value="1" id="operatingregion1" />
<label for="operatingregion1"> Nordjylland</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Midtjylland">
<input type="checkbox" name="operatingRegions" onclick=" " value="2" id="operatingregion2" />
<label for="operatingregion2"> Midtjylland</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Syd- og S&#248;nderjylland">
<input type="checkbox" name="operatingRegions" onclick=" " value="3" id="operatingregion3" />
<label for="operatingregion3"> Syd- og S&#248;nderjylland</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Fyn">
<input type="checkbox" name="operatingRegions" onclick=" " value="4" id="operatingregion4" />
<label for="operatingregion4"> Fyn</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Sj&#230;lland, &#216;erne og Bornholm">
<input type="checkbox" name="operatingRegions" onclick=" " value="5" id="operatingregion5" />
<label for="operatingregion5"> Sj&#230;lland, &#216;erne og Bornholm</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Stork&#248;benhavn">
<input type="checkbox" name="operatingRegions" onclick=" " value="6" id="operatingregion6" />
<label for="operatingregion6"> Stork&#248;benhavn</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Ikke oplyst">
<input type="checkbox" name="operatingRegions" onclick=" " value="7" id="operatingregion7" />
<label for="operatingregion7"> Ikke oplyst</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Hele landet">
<input type="checkbox" name="operatingRegions" onclick=" " value="8" id="operatingregion8" />
<label for="operatingregion8"> Hele landet</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Udlandet">
<input type="checkbox" name="operatingRegions" onclick=" " value="9" id="operatingregion9" />
<label for="operatingregion9"> Udlandet</label></div>
</div>


<br />
<b>Prisinterval:</b><br />
<input id="priceFrom" name="priceFrom" onkeypress=" " onkeyup=" " style="width: 75px;" type="text" value="" /> til <input id="priceTo" name="priceTo" onkeypress=" " onkeyup=" " style="width: 75px;" type="text" value="" />
<br />
<br />
<b>Etableringsår:</b><br />
<input id="yearFrom" name="yearFrom" onkeypress=" " onkeyup=" " style="width: 75px;" type="text" value="" /> til <input id="yearTo" name="yearTo" onkeypress=" " onkeyup=" " style="width: 75px;" type="text" value="" />
<br />
<br />
<b>Virksomheden skal kunne flyttes:</b><br />
<input checked="checked" id="canMoveNI" name="canMove" onclick=" " type="radio" value="" /> <label for="canMoveNI">Ikke vigtigt</label><br />
<input id="canMoveNo" name="canMove" onclick=" " type="radio" value="0" /> <label for="canMoveNo">Nej</label><br />
<input id="canMoveYes" name="canMove" onclick=" " type="radio" value="1" /> <label for="canMoveYes">Ja</label><br />
<br />
<b>Sælgerfinansiering skal tilbydes:</b><br />
<input checked="checked" id="financingAvailableNI" name="financingAvailable" onclick=" " type="radio" value="" /> <label for="financingAvailableNI">Ikke vigtigt</label><br />
<input id="financingAvailableNo" name="financingAvailable" onclick=" " type="radio" value="0" /> <label for="financingAvailableNo">Nej</label><br />
<input id="financingAvailableYes" name="financingAvailable" onclick=" " type="radio" value="1" /> <label for="financingAvailableYes">Ja</label><br />
<br />
<b>Sorter efter</b><br />
<select id="sortOrder" name="sortOrder" onchange=" "><option selected="selected" value="0">Relevans</option>
<option value="1">Oprettelsesdato (nyeste f&#248;rst)</option>
<option value="2">Oprettelsesdato (&#230;ldste f&#248;rst)</option>
<option value="3">Redigeringsdato (nyeste f&#248;rst)</option>
<option value="4">Redigeringsdato (&#230;ldste f&#248;rst)</option>
<option value="5">Pris (h&#248;jeste f&#248;rst)</option>
<option value="6">Pris (laveste f&#248;rst)</option>
</select><br />
</div>
<br />
<input type="submit" class="button_green" value="Søg igen &#x25BA;" id="SearchButton" name="SearchButton" style="float: left;" onclick=" _gaq.push(['_trackEvent', 'Ads_listing', 'search_again_click']); return false; " />
<input type="reset" class="button_small" value="Nulstil" id="ClearButton" style="float: right;" />

</form> </div>

<div class="boxfooter"></div>
</div>

<br />
<div id="EAS_f01c93ec" style="width:240px;height:auto;margin:0 auto;border:0;padding:0;"></div>
<script type="text/javascript">
$(document).ready(function() {
EAS_load_fif("EAS_f01c93ec", "/EAS_fif.html", "http://eas4.emediate.eu/eas?cu=1193;cre=mu;js=y;target=_blank;ord=635467592356970145", 240, 400);
});
</script>



</div>







<div style="clear: both;"></div>
<br />


<div id="bottomad" style="clear: both; text-align: center; margin: 0 auto 10px">
<div id="EAS_3b18704e" style="width:930px;height:180px;margin:0 auto;border:0;padding:0;"></div>
<script type="text/javascript">
$(document).ready(function() {
EAS_load_fif("EAS_3b18704e", "/EAS_fif.html", "http://eas4.emediate.eu/eas?cu=9947;cre=mu;js=y;target=_blank;ord=635467592359760305", 930, 180);
});
</script>

</div>



<div class="contentHeader"></div>
<div class="CommonContentBox">
<script language="javascript" type="text/javascript" src="http://www.amino.dk/content/amino-partners.js"></script>

</div>
<div class="contentFooter"></div>


</div>

<div style="clear: both;"></div>


</div>

<!-- (C)2000-2009 Gemius SA - gemiusAudience / amino.dk / Virksomhedsbors -->
<script type="text/javascript">
<!-- //--><![CDATA[//><!--
//modified 2013-02-11 rjs as per user specs. updates on gemius
var pp_gemius_identifier = 'bQ0w24csi_1RJcq7a4IMCqdFHWxgAe_a9eJp1cOw7Gf.f7';
(function (d, t) {
var ex; try {
var
gt = d.createElement(t), s = d.getElementsByTagName(t)[0], l = 'http' + ((location.protocol == 'https:') ? 's' : '');
gt.async = 'true'; gt.src = l + '://gadk.hit.gemius.pl/xlgemius.js'; s.parentNode.insertBefore(gt, s);
} catch (ex)
{ }
}(document, 'script'));
//end modified 2013-02-11 rjs as per user specs. updates on gemius
//--><!]]>
</script>

<script type="text/javascript">
var _sf_async_config = { uid: 17411, domain: "amino.dk" };
(function () {
function loadChartbeat() {
window._sf_endpt = (new Date()).getTime();
var e = document.createElement('script');
e.setAttribute('language', 'javascript');
e.setAttribute('type', 'text/javascript');
e.setAttribute('src',
(("https:" == document.location.protocol) ? "https://a248.e.akamai.net/chartbeat.download.akamai.com/102508/" : "http://static.chartbeat.com/") +
"js/chartbeat.js");
document.body.appendChild(e);
}
var oldonload = window.onload;
window.onload = (typeof window.onload != 'function') ?
loadChartbeat : function () { oldonload(); loadChartbeat(); };
})();

</script>

<!-- Visual Studio Browser Link -->
<script type="application/json" id="__browserLink_initializationData">
{"appName":"Chrome","requestId":"048073e31ed74ed68eeda96481c8bd4e"}
</script>
<script type="text/javascript" src="http://localhost:47739/1a675c31cef44fcca8dc0704a89a9da5/browserLink" async="async"></script>
<!-- End Browser Link -->

</body>
</html>

我迷路了。我已经搜索了几个小时了,但找不到导致回发的愚蠢 JS。有任何想法吗?这将是一个巨大的帮助。

编辑:

代码中引用了startUpdate。我尝试删除它,但仍然有回发。这是代码:

 function startUpdate(sender) {
if (tmr != null) clearTimeout(tmr);
tmr = setTimeout("updateSearch()", 700);
}

function updateSearch() {
tmr = null;
searchParams.transactiontype = $("input[name=transactionType]:checked").val();
searchParams.text = $("input[name=text]").val();
var sct = "";
$("input[name=sectors]:checked").each(function() { sct += $(this).val() + ","; });
searchParams.sector = sct;
searchParams.allsectorsrequired = $("#allSectorsRequired").attr("checked") == "checked" ? "true" : "";
var rgn = "";
$("input[name=regions]:checked").each(function() { rgn += $(this).val() + ","; });
searchParams.region = rgn;
var orgn = "";
$("input[name=operatingRegions]:checked").each(function() { orgn += $(this).val() + ","; });
searchParams.operatingregion = orgn;
searchParams.alloperatingregionsrequired = $("#allOperatingRegionsRequired").attr("checked") == "checked" ? "true" : "";
searchParams.priceFrom = $("input[name=priceFrom]").val();
searchParams.priceTo = $("input[name=priceTo]").val();
searchParams.yearFrom = $("input[name=yearFrom]").val();
searchParams.yearTo = $("input[name=yearTo]").val();
searchParams.canMove = $("input[name=canMove]:checked").val();
searchParams.financingavailable = $("input[name=financingAvailable]:checked").val();
searchParams.orderby = $("select[name=sortOrder]").val();

for (var key in searchParams) {
if ((!psp || psp[key] != searchParams[key]) && searchParams[key]) {
_gaq.push(['_trackEvent', 'Vbørs Søg autoupdate', key, searchParams[key]]);
}
}
psp = $.extend({}, searchParams);

$("#searchResults").load("@Url.Action("SearchJSON", "Search")", searchParams, searchCallback);

var tttxt = " til salg";
if (searchParams.transactiontype != 2) tttxt = " købes";

if (searchParams.text.length > 0) {
$("#searchtitle").text(searchParams.text + tttxt);
document.title = searchParams.text + tttxt;
}
}

最佳答案

根据我在评论中发布的内容,不知何故(您可能知道代码中发生这种情况)您的 onchange事件处理程序正在更改,从 startUpdate(this)top.location.href=sortLink.replace("{sortOrder}", this.value); .

所以,当 select更改时,它会替换页面 URL,这显然会导致刷新(通过 GET)。

关于c# - ASP.NET MVC DropDownList 导致我不期望的回发 - 似乎源自 JavaScript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25941358/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com