Ajax表单使用jQuery 1.11.2提交

时间:2015-12-11 09:13:44

标签: javascript jquery ajax

我有以下代码:

$(function() {
            $( "#dialog-confirm" ).dialog({
              resizable: false,
              height:250,
              width:530,
              modal: true,
              buttons: {
                "Save and Close": function() {
                    $('#frmSurvey').append("<input type='hidden' name='page' value='2' />");
                    var url = "save.php"; 

                    $.ajax({
                        type: "POST",
                        url: url,
                        data: $("#frmSurvey").serialize(), 
                        success: function(result){
                            var language = $("#lang").val();
                            var json = $.parseJSON(result);
                                if(json.response.status == 'success') {
                                        window.location.replace("finish.php?l=" + language);

                                } else {
                                    alert(json.response.message);
                                }

                        },
                        error: function(jqXHR, textStatus, errorThrown){
                            if (jqXHR.status === 0) {
                                            alert('Not connect.\n Verify Network.');
                                        } else  if (jqXHR.status == 503) {
                                            alert('Error: ' + jqHXR.responseText);
                                        }else if (jqXHR.status == 404) {
                                            alert('Requested page not found. [404]');
                                        } else if (jqXHR.status == 500) {
                                            alert('Internal Server Error. [500]');
                                        } else if (exception === 'parsererror') {
                                            alert('Requested JSON parse failed');
                                        } else if (exception === 'timeout') {
                                            alert('Time out error');
                                        } else if (exception === 'abort') {
                                            alert('Ajax request aborted');
                                        } else {
                                            alert('Uncaught Error.');
                                        }
                          }

                    });
                },
                Cancel: function() {
                  $( this ).dialog( "close" );
                }
              }
            });
          });

运行jQuery 1.11.2但是收到以下console错误消息,我无法理解错误:

Uncaught SyntaxError: Unexpected token <

m.parseJSON @   jquery-1.11.2.js:4
$.ajax.success  @   validate_honeywell_v2.js:220
j   @   jquery-1.11.2.js:2
k.fireWith  @   jquery-1.11.2.js:2
x   @   jquery-1.11.2.js:4
b   @   jquery-1.11.2.js:4

220 =

var json = $.parseJSON(result);

jQuery是否改变了处理方式?

0 个答案:

没有答案