2016-10-27 4 views
0

を動作していませんしようとすると、ユーザーの入力からテーブル "カレンダー"から日付配列を検索し、データベースと照合し、行2の対応する値を他のフィールド、およびVICE-VERSAに戻すフォームを取得します。AJAXとjQueryのオートフォームの更新は、これは私がフォームページに持っているものである

I.E.誰かが1つの事を入力すると、チェックし、他のものを追加してそれを保持します。今は現場にとどまっていません。何か不足していますか? $アヤックスコールと

答えて

0

号、 私はあなたのAJAX呼び出しを確認し、アプリケーションをので、あなたの$.ajaxコールmethod : "POST"に1つの以上のパラメータを追加し、それが動作しますGET URLを受け入れていないことを発見しました。

あなたは、コードの下に試すことができ

jQuery(document).ready(function($) { 
    $(document).on('focusout', '#dateenglish', function() { 
     var dateenglish = $(this).val(); 
     $.ajax({ 
      url: 'http://www.mountsinaiparks.org/digital-yahrzeit/wp-content/themes/yahrzeit-theme/getdate.php', 
      method : "POST", 
      data: { 
       'dateenglish': dateenglish 
      }, 
      success:function(data) { 
       // This outputs the result of the ajax request 
       $('#dateenglish').val(data); 
      }, 
      error: function(errorThrown){ 
       console.log(errorThrown); 
      } 
     }); 
    }); 
    }); 

更新PHPの

<?php 
    include_once($_SERVER['DOCUMENT_ROOT'].'/wp-load.php'); 
    // Do the following if the form submits 
    if (isset($_REQUEST['dateenglish'])) { 
    $date = $_REQUEST['dateenglish']; 

    global $wpdb; 

    $stmt = "SELECT 
    heb_date, 
    greg_date 
    FROM calendar 
    WHERE greg_date = '".$date."' 
    OR heb_date = '".$date."' 
    "; 

    $myrows = $wpdb->get_results($stmt); 

    // Not sure if its an array that is returned, but this will get the first value. 

    while ($row = $myrows->fetch_field()){ 
     // Let's check which date is different 
     if ($date != $row['greg_date']) { 
      $date = $row['greg_date']; 
     } else { 
      $date = $row['heb_date']; 
     } 
     echo $date; 
     return; 
    } 




    } else { 
    echo 'error'; 
    } 
    ?> 
+0

日は、ちょうど焦点うちに消えます。奇妙な –

+0

'$ data'のbecozが空であるかもしれません。データベースレコードを確認してください。 – Veer

+0

テーブルに$ data行がなく、 "greg_date"と "heb_date"という名前です –

関連する問題