0

私はAjaxFormプラグインを使用しています

サーバーに何がプッシュされているかをデータに警告したい。

<form class='frmAppList'>
    <input type='hidden' name='deviceid' value='<deviceId>'>
    <input type='hidden' name='operationtype' value='<Coming from server>'>
    <input type='hidden' name='type' value='command'>
    <button type="submit" class='btnAppsList button'>
         APPS LIST
    </button>
</form>

これはjspでループしているため、クラス-> frmAppListを持つフォームが複数回生成されます。

クラスを使用して、次のようにajaxformを適用しています。

$('.frmAppList').ajaxForm({
   url : 'urltoserver',
   dataType : 'json',
   type : 'post',
   beforeSubmit : function() {
     return false;
     //something here that gives me the device id that is passed
     //since the form is not one I cant use id, also every form has **deviceid**
     //i need to get that deviceid so that i can pass it in **success** ajax call
     //at ***Label->(A)*** 
   },
   success : function(response) {
      if (response.status) {
        //***Label*** ->(A)
        //have to call other ajax call to take the data 
        //for that i need the device id that is going in this ajax call
      }
   },
   error : function(xhr, ajaxOptions, thrownError) {
      alert('error');
   },
   timeout :10000
});

そのデバイスIDを取得するにはどうすればよいですか、助けてください....ありがとうございます.....

4

1 に答える 1

2

ajaxForm doc から:

success
Callback function to be invoked after the form has been submitted. If a 'success' callback function is provided it is invoked after the response has been returned from the server. It is passed the following arguments:
1.) responseText or responseXML value (depending on the value of the dataType option).
2.) statusText
3.) xhr (or the jQuery-wrapped form element if using jQuery < 1.4)
4.) jQuery-wrapped form element (or undefined if using jQuery < 1.4)
Default value: null

3 番目と 4 番目の引数は、探しているものです。そこから始めます:

success : function(response,status,request,form) {
  console.log(request,form);
}
于 2012-10-03T12:10:28.903 に答える