Jquery Load Sorunu?
-
Bu JQuery bana çok ciddi sıkıntılar yaşatıyor. Örneğin ; http://www.domain.com/deneme.asp sayfasında istediğim gibi sayfayı belirli aralıkta load edip eğerhttp://www.domain.com/kontrol.asp sayfasında içerik varsa ekrana yazdırıyor. İşlemi Chrome ile F12 basıp Console' den takip ettiğimde hiçbir sorunun olmadığı gözüküyor. Yalnız ;
Eğer oradaki kodu aynen kopyalayıp seo' lu http://www.domain.com/default.asp sayfasına attığımda "XMLHttpRequest cannot load http://www.domain.com/kontrol.asp. The request was redirected to 'http://domain.com/kontrol.asp', which is disallowed for cross-origin requests that require preflight. " hatası ile karşılaşıyorum.
Mantık olarak orda çalışan kodun bu sayfalarda da çalışması lazım. Oldu ya kütüphane çakışması olsa altta ki diğer kodlarıda etkiler. Bu hata sadece seo sayfasında tanımlı olan dosyalarda sayfa load edince karşıma çıkıyor. Normal sayfalarda sayfaları rahatlıkla load edip hatta resimleri dahi upload edebiliyorum sorunsuz bir şekilde.. Ama ben buna akıl sır mantık erdiremedim. Aksine localhost' ta da sorunsuz çalışıyor. Bu sorun genelde kronikleşmiş ve genelde yazılan feedback' ler'den birinin yazılı olduğu linki anektod olarak aynen aktarıyorum.
"http://stackoverflow.com/questions/22389694/cross-domain-ajax-request-not-working"
Lütfen bir yol gösterin..
PHP- Kodu:<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("#veriler").load("Kontrol.asp");
});
setInterval(function() {$("#veriler").load('Kontrol.asp');}, 30000);
</script>
<div id="veriler"></div> -
Cross domain problemi genelde http https veya başka bir bağlantıdan veri çekmeyle alakalıdır. Ama senin sıkıntını anlamadım hepsini .asp olarak göstermişsin seo olarak aspde 404 kullanırsın ve .htmlden öteye geçmez. E abü senin bu verdiğin linkler komple .asp?
-
by_Tet bunu yazdı
Cross domain problemi genelde http https veya başka bir bağlantıdan veri çekmeyle alakalıdır. Ama senin sıkıntını anlamadım hepsini .asp olarak göstermişsin seo olarak aspde 404 kullanırsın ve .htmlden öteye geçmez. E abü senin bu verdiğin linkler komple .asp?
Evet... çıldırmak üzereyim. Seo' lu sayfalarda a.sp, .php, .html load etmiyor. Ama diğer load olmayan sliderler, efectler v.s tüm jquery tabanlı kodlar çalışıyor. Web.config'de olabilir mi? diye düşünüyorum.
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="*" /> <add name="Access-Control-Allow-Methods" value="GET,POST,OPTIONS" /> <add name="Access-Control-Allow-Headers" value="*" /> </customHeaders> </httpProtocol> <directoryBrowse enabLED="false" /> <validation validateIntegratedModeConfiguration="false" /> <httpErrors errorMode="Custom" existingResponse="Auto"> <remove statusCode="404" subStatusCode="-1" /> <remove statusCode="403" subStatusCode="-1" /> <remove statusCode="401" subStatusCode="-1" /> <remove statusCode="405" subStatusCode="-1" /> <remove statusCode="406" subStatusCode="-1" /> <remove statusCode="412" subStatusCode="-1" /> <remove statusCode="500" subStatusCode="-1" /> <remove statusCode="501" subStatusCode="-1" /> <remove statusCode="502" subStatusCode="-1" /> <remove statusCode="503" subStatusCode="-1" /> <error statusCode="403" prefixLanguageFilePath="" path="/404.asp" responseMode="ExecuteURL" /> <error statusCode="404" prefixLanguageFilePath="" path="/404.asp" responseMode="ExecuteURL" /> <error statusCode="405" prefixLanguageFilePath="" path="/404.asp" responseMode="ExecuteURL" /> <error statusCode="406" prefixLanguageFilePath="" path="/404.asp" responseMode="ExecuteURL" /> <error statusCode="412" prefixLanguageFilePath="" path="/404.asp" responseMode="ExecuteURL" /> <error statusCode="500" prefixLanguageFilePath="" path="/404.asp" responseMode="ExecuteURL" /> <error statusCode="501" prefixLanguageFilePath="" path="/404.asp" responseMode="ExecuteURL" /> <error statusCode="502" prefixLanguageFilePath="" path="/404.asp" responseMode="ExecuteURL" /> <error statusCode="503" prefixLanguageFilePath="" path="/404.asp" responseMode="ExecuteURL" /> </httpErrors> </system.webServer> </configuration>
UmutxTR tarafından 15/Tem/14 14:33 tarihinde düzenlenmiştir -
Eve gidince bi bakalım hocam max yarım saate evdeyim..
-
by_Tet bunu yazdı
Eve gidince bi bakalım hocam max yarım saate evdeyim..
Teşekkür ederim. Acil bu konuyu çözmemiz lazım. Kilitlendik kaldık resmen. Akıl mantık dışı saçma sapan bir durum bu ya :(
-
ajax ile çalışıyosan ya www prefixini kullan ya da kullanma.
tahribatta da aynı sorun var. mesela www.tahribat.com a login olduğunda tahribat.com da oturum açılmıyor. çünkü çerezler aynı değil.
en temizi birini seçip diğerine yönlendirme yapmak.
nginx için ;
if ($http_host != www.domain.com) {
rewrite (.*) http://www.domain.com$1;
}
apache için ;
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L] -
Cors kafa yoruyor çok ya. Sayfalar aynı subdomain de mi hocam?
-
Hybris bunu yazdı
ajax ile çalışıyosan ya www prefixini kullan ya da kullanma.
tahribatta da aynı sorun var. mesela www.tahribat.com a login olduğunda tahribat.com da oturum açılmıyor. çünkü çerezler aynı değil.
en temizi birini seçip diğerine yönlendirme yapmak.
nginx için ;
if ($http_host != www.domain.com) {
rewrite (.*) http://www.domain.com$1;
}
apache için ;
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.domain\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]Konu ile ilgili daha ayrıntılı bilgileri nasıl alabiliriz. Tam anlayamadım bu işlemi nerede nasıl hangi dosyalar üzerinde gerçekleştireceğiz. Ayrıca sayfalarımız .Asp ..
-
KrypT bunu yazdı
Cors kafa yoruyor çok ya. Sayfalar aynı subdomain de mi hocam?
Sayfaların hepsi aynı yerde subdomain kullanmıyoruz. Aynı dizinde yani şöyle bir saçmalık olabilir mi ? Aynı dizinde deneme.asp ' de kodlar çalışıyor ama seo' da tanımlı default.asp ya da deneme1112.asp 'de çalışmıyor. Kafayı yemek üzereyim.. Bilmemek ne kötü bir şeydir böyle..
-
hakkaten he asp yazmışın ben php ye göre izah ettim.
http://www.domain.com/kontrol.asp
burayı çekmeye çalıştığında
buraya yönlendiriyor. o yüzden de hata alıyorsun. sebebi alttaki linkte.
http://en.wikipedia.org/wiki/Same-origin_policy
yani yaptığın işlem bir başka sitedeki verileri jquery ile kendi sitene load etmeye çalışmakla aynı şey.
bunu gidermen lazım. aspyi nerden nasıl konfigüre ediyorsunuz bilgim yok.
scriptin yapısı ile de alakalı tabi.
Hybris tarafından 15/Tem/14 14:25 tarihinde düzenlenmiştir -
Hybris bunu yazdı
hakkaten he asp yazmışın ben php ye göre izah ettim.
http://www.domain.com/kontrol.asp
burayı çekmeye çalıştığında
buraya yönlendiriyor. o yüzden de hata alıyorsun. sebebi alttaki linkte.
http://en.wikipedia.org/wiki/Same-origin_policy
yani yaptığın işlem bir başka sitedeki verileri jquery ile kendi sitene load etmeye çalışmakla aynı şey.
bunu gidermen lazım. aspyi nerden nasıl konfigüre ediyorsunuz bilgim yok.
scriptin yapısı ile de alakalı tabi.
Hocam, sorun ile ilgili çözüm önerilerinde "http://stackoverflow.com/questions/22389694/cross-domain-ajax-request-not-working" adresinde yazılı olan bir kaç öneride var yalnız çat-pat ingilizcemizle tercüme ettiğimiz kadarıyla orda anlatılanlarıda update ettik yukarıda gönderdiğim gibi web.config dosyamız'da aşağıda nerede hata yapıyoruz ya da eksik var ? İngilizcesi iyi olan bize yukardaki çözüm önerisinde anlamadığımız noktalarıda açıklayabilir mi ?
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="*" /> <add name="Access-Control-Allow-Methods" value="GET,POST,OPTIONS" /> <add name="Access-Control-Allow-Headers" value="*" /> </customHeaders> </httpProtocol> <directoryBrowse enabLED="false" /> <validation validateIntegratedModeConfiguration="false" /> <httpErrors errorMode="Custom" existingResponse="Auto"> <remove statusCode="404" subStatusCode="-1" /> <remove statusCode="403" subStatusCode="-1" /> <remove statusCode="401" subStatusCode="-1" /> <remove statusCode="405" subStatusCode="-1" /> <remove statusCode="406" subStatusCode="-1" /> <remove statusCode="412" subStatusCode="-1" /> <remove statusCode="500" subStatusCode="-1" /> <remove statusCode="501" subStatusCode="-1" /> <remove statusCode="502" subStatusCode="-1" /> <remove statusCode="503" subStatusCode="-1" /> <error statusCode="403" prefixLanguageFilePath="" path="/404.asp" responseMode="ExecuteURL" /> <error statusCode="404" prefixLanguageFilePath="" path="/404.asp" responseMode="ExecuteURL" /> <error statusCode="405" prefixLanguageFilePath="" path="/404.asp" responseMode="ExecuteURL" /> <error statusCode="406" prefixLanguageFilePath="" path="/404.asp" responseMode="ExecuteURL" /> <error statusCode="412" prefixLanguageFilePath="" path="/404.asp" responseMode="ExecuteURL" /> <error statusCode="500" prefixLanguageFilePath="" path="/404.asp" responseMode="ExecuteURL" /> <error statusCode="501" prefixLanguageFilePath="" path="/404.asp" responseMode="ExecuteURL" /> <error statusCode="502" prefixLanguageFilePath="" path="/404.asp" responseMode="ExecuteURL" /> <error statusCode="503" prefixLanguageFilePath="" path="/404.asp" responseMode="ExecuteURL" /> </httpErrors> </system.webServer> </configuration>
UmutxTR tarafından 15/Tem/14 14:34 tarihinde düzenlenmiştir