Ajax失败并返回错误

时间:2018-06-28 22:41:32

标签: javascript jquery ajax

首先我正在使用该脚本

$.ajax({
		type: 'POST',
		url: 'ajax/registration.php',
		data: dataObj,
		dataType: 'json',
		async: true,
	})
	.done(function ajaxDone(data) {
		// Whatever data is 
		if(data.redirect !== undefined) {
			window.location = data.redirect;
		} else if(data.error !== undefined) {
			_error
				.text(data.error)
				.show();
		}
	})
	.fail(function ajaxFailed(e) {
		// This failed 
		console.log(e);
	})
	.always(function ajaxAlwaysDoThis(data) {
		// Always do
		console.log('Always');
	})

我正在创建一个注册系统,我应该将DataObj发送到服务器,但是ajax失败并给我该错误:-

Object { readyState: 4, getResponseHeader: getResponseHeader(), getAllResponseHeaders: getAllResponseHeaders(), setRequestHeader: setRequestHeader(), overrideMimeType: overrideMimeType(), statusCode: statusCode(), abort: abort(), state: state(), always: always(), catch: catch(), … } main.js:46:3

以及有关错误消息的更多详细信息:-

{…}​abort: function abort()​always: function always()​catch: function catch()​done: function add()​fail: function add()​getAllResponseHeaders: function getAllResponseHeaders()​getResponseHeader: function getResponseHeader()​overrideMimeType: function overrideMimeType()​pipe: function pipe()​progress: function add()​promise: function promise()​readyState: 4​responseText: "<br />\n<b>Fatal error</b>:  Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY' in /opt/lampp/htdocs/Registration and login System/ajax/registration.php:27\nStack trace:\n#0 /opt/lampp/htdocs/Registration and login System/ajax/registration.php(27): PDOStatement-&gt;execute()\n#1 {main}\n  thrown in <b>/opt/lampp/htdocs/Registration and login System/ajax/registration.php</b> on line <b>27</b><br />\n"​setRequestHeader: function setRequestHeader()​state: function state()​status: 200​statusCode: function statusCode()​statusText: "OK"​then: function then()​<prototype>: Object { … } main.js:46:3

有人可以告诉我这个错误可能在哪里/什么地方吗?

0 个答案:

没有答案