Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [jQuery]Problem z $.ajax
GameMaker
post
Post #1





Grupa: Zarejestrowani
Postów: 149
Pomógł: 2
Dołączył: 31.01.2010
Skąd: Konstancin-Jeziorna

Ostrzeżenie: (0%)
-----


Witajcie !

Mam problem z funkcją $.ajax. Zamiast pobierać dane do diva , wyświetla stronę z wynikiem.


Mój kod :

  1. <script type="text/javascript">
  2. var urlser = 'watchme.php?id=';
  3.  
  4. $.ajax({
  5. type: 'GET',
  6. url: urlser + $('[name=movie_id]').val(),
  7. success: function(data){
  8. $('#players').html(data);
  9. }
  10. });
  11.  


Ten post edytował GameMaker 20.06.2011, 16:08:11
Go to the top of the page
+Quote Post
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 559
Pomógł: 6315
Dołączył: 27.12.2004




Bo może Twoje data zawiera właśnie stronę z wynikiem.
Go to the top of the page
+Quote Post
GameMaker
post
Post #3





Grupa: Zarejestrowani
Postów: 149
Pomógł: 2
Dołączył: 31.01.2010
Skąd: Konstancin-Jeziorna

Ostrzeżenie: (0%)
-----


właśnie data zwraca skrypt kodowany w tym stylu :

  1.  
  2. document.write('\x3c\x65\x6d\x62\x65\x64\x20\x73\x72\x63\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x77
    \x77\x77\x73\x74\x61\x74\x69\x63\x2e\x6d\x65\x67\x61\x76\x69\x64\x65\x6f\x2e\x63\
    x6f\x6d\x2f\x6d\x76\x5f\x70\x6c\x61\x79\x65\x72\x2e\x73\x77\x66\x3f\x76\x3d\x39\x
    36\x48\x44\x38\x34\x43\x48\x22\x20\x74\x79\x70\x65\x3d\x22\x61\x70\x70\x6c\x69\x6
    3\x61\x74\x69\x6f\x6e\x2f\x78\x2d\x73\x68\x6f\x63\x6b\x77\x61\x76\x65\x2d\x66\x6c
    \x61\x73\x68\x22\x20\x66\x6c\x61\x73\x68\x76\x61\x72\x73\x3d\x22\x67\x63\x6f\x64\
    x65\x3d\x34\x38\x32\x43\x44\x36\x39\x37\x22\x20\x6d\x65\x6e\x75\x3d\x22\x66\x61\x
    6c\x73\x65\x22\x20\x71\x75\x61\x6c\x69\x74\x79\x3d\x22\x68\x69\x67\x68\x22\x20\x6
    1\x6c\x6c\x6f\x77\x66\x75\x6c\x6c\x73\x63\x72\x65\x65\x6e\x3d\x22\x74\x72\x75\x65
    \x22\x20\x77\x69\x64\x74\x68\x3d\x22\x35\x30\x30\x22\x20\x68\x65\x69\x67\x68\x74\
    x3d\x22\x33\x30\x30\x22\x3e\x3c\x2f\x65\x6d\x62\x65\x64\x3e');
  3.  
  4.  
  5.  


Ten post edytował GameMaker 20.06.2011, 16:11:53
Go to the top of the page
+Quote Post
nospor
post
Post #4





Grupa: Moderatorzy
Postów: 36 559
Pomógł: 6315
Dołączył: 27.12.2004




Przecież document.write() właśnie wszystko nadpisuje, stąd masz efekt jaki masz. Skąd pomysł, by używać takiego starocia?


Napisz co chcesz zrobić.

Go to the top of the page
+Quote Post
GameMaker
post
Post #5





Grupa: Zarejestrowani
Postów: 149
Pomógł: 2
Dołączył: 31.01.2010
Skąd: Konstancin-Jeziorna

Ostrzeżenie: (0%)
-----


watchme.php generuje z bazy danych player megavideo.
Do diva chę wstawić za pomocą jquery ten player.

Czyli wnioskuje żeby usunąć to hashowanie i dać sam html (embedy).
Go to the top of the page
+Quote Post
nospor
post
Post #6





Grupa: Moderatorzy
Postów: 36 559
Pomógł: 6315
Dołączył: 27.12.2004




Zapewne tak.
Go to the top of the page
+Quote Post
GameMaker
post
Post #7





Grupa: Zarejestrowani
Postów: 149
Pomógł: 2
Dołączył: 31.01.2010
Skąd: Konstancin-Jeziorna

Ostrzeżenie: (0%)
-----


Coś dziwnego mi wyrzuca , zamiast pobierać z inputa movie_id , identyfikatora filmu daje wartość undefined.
Go to the top of the page
+Quote Post
nospor
post
Post #8





Grupa: Moderatorzy
Postów: 36 559
Pomógł: 6315
Dołączył: 27.12.2004




Bo może regułka:
$('[name=movie_id]')
nie zwraca ci pola, które szukasz. No wszystko trzeba pokolei palcem pokazywać? Sprawdź coś sam.
Go to the top of the page
+Quote Post
GameMaker
post
Post #9





Grupa: Zarejestrowani
Postów: 149
Pomógł: 2
Dołączył: 31.01.2010
Skąd: Konstancin-Jeziorna

Ostrzeżenie: (0%)
-----


$('[name=movie_id]').val()

Zmieniłem na $('#movie_id').val() i tak samo jest
Go to the top of the page
+Quote Post
nospor
post
Post #10





Grupa: Moderatorzy
Postów: 36 559
Pomógł: 6315
Dołączył: 27.12.2004




A masz pole o ID=movie_id ?
Go to the top of the page
+Quote Post
GameMaker
post
Post #11





Grupa: Zarejestrowani
Postów: 149
Pomógł: 2
Dołączył: 31.01.2010
Skąd: Konstancin-Jeziorna

Ostrzeżenie: (0%)
-----


mój input :

<input type="hidden" id="movie_id" value="96HD84CH" >
Go to the top of the page
+Quote Post
nospor
post
Post #12





Grupa: Moderatorzy
Postów: 36 559
Pomógł: 6315
Dołączył: 27.12.2004




No to powinno działać.
A co ci zwraca:
alert($('#movie_id').val());
?
Go to the top of the page
+Quote Post
GameMaker
post
Post #13





Grupa: Zarejestrowani
Postów: 149
Pomógł: 2
Dołączył: 31.01.2010
Skąd: Konstancin-Jeziorna

Ostrzeżenie: (0%)
-----


undefined wyskakuje
Go to the top of the page
+Quote Post
nospor
post
Post #14





Grupa: Moderatorzy
Postów: 36 559
Pomógł: 6315
Dołączył: 27.12.2004




znaczy ze nie masz takiego pola. Gdzie masz to pole? W głównym skrypcie czy w skrypcie które zwraca ajax?
Kiedy pobierasz to pole, po tym jak się strona wygenerowała czy może w trakcie generowania strony. No jak w trakcie to tego pola może jeszcze nie być.
Go to the top of the page
+Quote Post
GameMaker
post
Post #15





Grupa: Zarejestrowani
Postów: 149
Pomógł: 2
Dołączył: 31.01.2010
Skąd: Konstancin-Jeziorna

Ostrzeżenie: (0%)
-----


Pole jest w głównym skrypcie.

link :
http://frikofilm.pl/link.php
Go to the top of the page
+Quote Post
nospor
post
Post #16





Grupa: Moderatorzy
Postów: 36 559
Pomógł: 6315
Dołączył: 27.12.2004




I tu się kłania to co napisałem wcześniej:
Kiedy pobierasz to pole, po tym jak się strona wygenerowała czy może w trakcie generowania strony. No jak w trakcie to tego pola może jeszcze nie być.

Pobierasz wartość pola, które się jeszcze nie wygenerowało. Alert należy robić dopiero po wygenerowaniu się strony.
Go to the top of the page
+Quote Post
GameMaker
post
Post #17





Grupa: Zarejestrowani
Postów: 149
Pomógł: 2
Dołączył: 31.01.2010
Skąd: Konstancin-Jeziorna

Ostrzeżenie: (0%)
-----


Działa dzięki.

Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 4.10.2025 - 13:34