2017-01-16 9 views
0
<script> 
    $(document).ready(function() { 
    $.ajax({url: "http://somedomain/app/district.php", success: function(result){ 
    $("#district").html(result); 
    }}); 

    $.ajax({url: "http://somedomain/app/category.php", success: function(result){ 
    $("#crop-category").html(result); 
    }}); 

     $('#district').change(function(){ 
    var value=$('#district').val(); 
    $('#upazila').parent().find('span').html("<span>&nbsp;</span>"); 
    $.ajax({ 
     url: "http://somedomain/app/upazila.php", 
     type: "get", //send it through get method 
     data:{value}, 
     success: function(response) { 
     $("#upazila").html(response); 
     }, 
     error: function(xhr) { 
     //Do Something to handle error 
     } 
    }); 

}); 

    }); 

</script> 

これは私のjqueryコードです。 最初の2つのAjaxリクエストのために値を取得しましたが、要求を取得して変数を渡すとコードが機能しません。デバッグ気分でそれが キャッチされないでSyntaxError言う:予期しないトークン}のindex.html:36 phonegap ajaxは値で動作していません

データです:{値}、

が、それは助けてくださいブラウザ... で正常に動作します。

答えて

0

問題があなたの第三ajax呼び出しで、dataフィールドが有効なオブジェクトではないということです、dataは、オブジェクト、文字列または配列でなければなりません。以下に示すようにvalueを渡し:

​​

あなたは花の括弧内のそれを言及する必要はありません。または、文字列または配列でオブジェクトとして渡す場合は、次のように渡します。

data: {value: value} 
関連する問題