AJAX / PHP不起作用

时间:2015-08-15 12:49:29

标签: javascript php jquery ajax

所以我想使用AJAX将一些数据(从表单)提交到服务器数据库,但由于某种原因,它接收到AJAX脚本根本不工作。当我提交表单时,PHP脚本执行没有问题。我到处寻找答案但到目前为止没有任何工作。这可能是愚蠢的,但无论如何我都需要一些帮助。

Jquery / AJAX脚本:

public partial class ThisAddIn
   {
      Word.Application application;
      string insertText = "INSERT!!";
      Office.CommandBarButton acceptButton;
      Office.CommandBar commandBar;

      private void ThisAddIn_Startup(object sender, System.EventArgs e)
      {
         application = this.Application;
         application.WindowBeforeRightClick +=
             new Word.ApplicationEvents4_WindowBeforeRightClickEventHandler(application_WindowBeforeRightClick);         

         application.DocumentOpen += 
             new Word.ApplicationEvents4_DocumentOpenEventHandler(WorkWithDocument);

         ((Word.ApplicationEvents4_Event)this.Application).NewDocument +=
             new Word.ApplicationEvents4_NewDocumentEventHandler(WorkWithDocument);

      }

      private void WorkWithDocument(Microsoft.Office.Interop.Word.Document Doc)
      {
         try
         {
            application.CustomizationContext = application.ActiveDocument;
            commandBar = application.CommandBars["Track Changes"];
            acceptButton = (Office.CommandBarButton)commandBar.Controls.Add(
                Office.MsoControlType.msoControlButton);
            acceptButton.accName = insertText;
            acceptButton.Caption = insertText;              
            acceptButton.Click += new Office._CommandBarButtonEvents_ClickEventHandler(ButtonClick);
         }
         catch (Exception ex)
         {
            Debug.Print(ex.StackTrace);

            // Handle exception if for some reason the document is not available.
         }
      }

      // Handles the event when a button on the new toolbar is clicked. 
      private void ButtonClick(Office.CommandBarButton ctrl, ref bool cancel)
      {
         try
         {
            Debug.Print("You clicked: " + ctrl.Caption);
         }
         catch (Exception ex)
         {
            Debug.Print(ex.Message);
         }
      }

...

});

PHP和HTML脚本:

$(document).ready(function() {
 $('#InputForm').submit(function(){

     var that = $(this),
         url = that.attr('action'),
         type = that.attr('method'),
         data = {};


     that.find('[name]').each(function(index, value){
         var that = $(this),
             name = that.attr('name'),
             value = that.val();

         data[name] = value;    
     });

    $.ajax({
        url: url,
        async: true,
        type: type,
        data: data,
        success: function(response){
            $(#Suc_Sub).fadeIn(800);
        }
    });
    return false;
});  

感谢任何形式的帮助。非常感谢。

0 个答案:

没有答案