Php 我有一个单独的字段(不是一种形式),我想使用ajax发送它们的数据

Php 我有一个单独的字段(不是一种形式),我想使用ajax发送它们的数据,php,jquery,ajax,Php,Jquery,Ajax,这是我的jquery代码: var category= $('#category').val(); var week = $('#week').val(); var data = {'category': category , 'week': week , 'class': classification , 'pset': pset , 'text_question': question , 'question_keys': keywords}; $.ajax({

这是我的jquery代码:

var category= $('#category').val();

var week = $('#week').val();

var data = {'category': category , 'week': week , 'class': classification , 'pset': pset , 'text_question': question , 'question_keys': keywords};

        $.ajax({
            url: 'post_question.php',  //Server script to process data
            type: 'POST',
            xhr: function() {  // Custom XMLHttpRequest
                var myXhr = $.ajaxSettings.xhr();
                return myXhr;
            },
            //Ajax events
            success: function(output){
                         if(output == 'success')   
                         {
                            alert("success");                                
                         }
                         else
                         {  
                            alert("failed");
                         }
                     },
            error: function(){
                       alert("Error sending question to database!!"); 
                   },
            // Form data
            data: data,
            //Options to tell jQuery not to process data or worry about content-type.
            cache: false,
            contentType: true,
            processData: false
       });    

那么你的问题是什么呢?这是我的php代码,它接收来自请求的数据。为什么你试图发送的输入不是以相同的形式?我们能看到相关的HTML吗?请记住编辑您的原始问题。