0
我正在使用json helper和jquery.form.js處理webmatrix。數據發送到服務器後,我的反應數據是這樣的:json響應格式
「\ u003cli \ u003monster2010是不是一個有效的電子郵件\ u003c /李\ u003e。」「\ u003cli \ [email protected]已在使用通過你\ u003c /李\ u003e」
StringWriter writer = new StringWriter();
Json.Write("<li>" + user_mobile[i] + " is already in use by you.</li>", writer);
Json.Write("<li>" + user_mobile[i] + " is not a valid phone number.</li>", writer);
Response.Write(writer);
我也試圖利用編碼
var json = json.Encode(writer); //razor
我也試過編劇:
Json.Write(Json.Encode("<li>" + user_mobile[i] + " is already in use by you.</li>"), writer);
Json.Write(Json.Encode("<li>" + user_mobile[i] + " is not a valid phone number.</li>"), writer);
var options = {
// target: '#', // target element(s) to be updated with server response
beforeSubmit: showRequest, // pre-submit callback
success: showResponse, // post-submit callback
// other available options:
//url: url // override for form's 'action' attribute
//type: type // 'get' or 'post', override for form's 'method' attribute
dataType: 'json' // 'xml', 'script', or 'json' (expected server response
};
// bind to the form's submit event
$('#frm_basicinfo').submit(function() {
$(this).ajaxSubmit(options);
return false;
});
function showRequest(formData, jqForm, options) {
var queryString = $.param(formData);
alert('About to submit: \n\n' + queryString);
return true;
}
// post-submit callback
function showResponse(responseText, statusText, xhr, $form) {
alert('status: ' + statusText + '\n\nresponseText: \n' + responseText);
}
可以幫助嗎?
謝謝......指出! –