PHP Jquery sonrası seçenek değeri

3 Cevap php

Nasıl PHP seçilen veri jQuery kullanarak veri gönderebilir miyim?

HTML kodu:

<select id="test" title="test" class="test">
  <option value="1">1
  <option value="2">2
  <option value="3">3
  <option value="4">4
  <option value="5">5
 </select>

JQuery:

$('.18').click(function(event) {
  var test_s = $('#test').val();
  $('.opc_mfont').load("index.php?x=18&fid=<?=$fid;?>&mid=<?=$mid;?>&data=' + test_s +'");
  event.stopPropagation();
});

Tüm veriler başarıyla at ve jquery load () ve '+ test_s +' dışında PHP ve MySQL sorgu göndermek oldu.

Ben veri ile alanları seçin alınan bu test edilmiştir "alert (test_s);" ve uyarı mesajı üzerine doğru verilerle ortaya. Ama ben jquery load () kullanarak PHP "var test_s" gönderemezsiniz. Bunu nasıl yapabilirim?

3 Cevap

read

. jQuery yükten ():

The POST method is used if data is provided as an object; otherwise, GET is assumed.

burada okuyun: http://api.jquery.com/load/

code

Bu gibi denenmemiş, muhtemelen bir şey:

$('.opc_mfont').load("index.php?x=18&fid=<?=$fid;?>&mid=<?=$mid;?>", {'data':test_s});

Sizin sorun dizedir:

"index.php?x=18&fid=<?=$fid;?>&mid=<?=$mid;?>&data=' + test_s +'"

Bu dize birleştirme değil - Eğer dize sınırlayıcı karıştırma ediyoruz. İstediğiniz:

"index.php?x=18&fid=<?=$fid;?>&mid=<?=$mid;?>&data=" + test_s

Eğer tek ve çift tırnak kadar karışık:

$('.18').click(function(event) {
  var test_s = $('#test').val();
  $('.opc_mfont').load('index.php?x=18&fid=<?=$fid;?>&mid=<?=$mid;?>&data=' + test_s);
  event.stopPropagation();
});