0

IE9に付属の開発者ツールを使用して、Webサーバーにデータを投稿したいと思います。手順は次のとおりです。F12をクリックし、[コンソール]タブをクリックしてコンソールを開き、次のスクリプトを実行します。

jQuery.ajax ({
url: myurl,
type: "POST",
data: JSON.stringify({data:"test"}),
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function(){
    alert ("success")
}});  

しかし、私はいつも得ました:{

readyState : 1,
setRequestHeader : function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},
getAllResponseHeaders : function(){return s===2?n:null},
getResponseHeader : function(a){var c;if(s===2){if(!o){o={};while(c=bH.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},
overrideMimeType : function(a){s||(d.mimeType=a);return this},
abort : function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this},
done : function(){if(c){var a=c.length;m(arguments),i?k=c.length:e&&e!==!0&&(j=a,n(e[0],e[1]))}return this},
fail : function(){if(c){var a=c.length;m(arguments),i?k=c.length:e&&e!==!0&&(j=a,n(e[0],e[1]))}return this},
progress : function(){if(c){var a=c.length;m(arguments),i?k=c.length:e&&e!==!0&&(j=a,n(e[0],e[1]))}return this},
state : function(){return e}
...

}

誰かがそれが何であるか教えてもらえますか?コードが正常に実行されたかどうかを知るにはどうすればよいですか?

4

1 に答える 1

0

jQuery.ajax メソッドは、成功コールバックの結果ではなく、jqXHRオブジェクトを返します。成功のコールバックに名前付き関数を使用して、結果をテストします。

function foo()
  {
  console.log(arguments.statusText);
  }

var bar = 
{
  "filter": "default",
  "included_fields": [
    ".backoff",
    ".error_id",
    ".error_message",
    ".error_name",
    ".has_more",
    ".items",
    ".quota_max",
    ".quota_remaining",
    "access_token.access_token",
    "access_token.account_id",
    "access_token.expires_on_date",
    "access_token.scope",
    "account_merge.merge_date",
    "account_merge.new_account_id",
    "account_merge.old_account_id",
    "answer.answer_id",
    "answer.community_owned_date",
    "answer.creation_date",
    "answer.is_accepted",
    "answer.last_activity_date",
    "answer.last_edit_date",
    "answer.locked_date",
    "answer.owner",
    "answer.question_id",
    "answer.score",
    "badge.award_count",
    "badge.badge_id",
    "badge.badge_type",
    "badge.link",
    "badge.name",
    "badge.rank",
    "badge.user",
    "badge_count.bronze",
    "badge_count.gold",
    "badge_count.silver",
    "closed_details.by_users",
    "closed_details.description",
    "closed_details.on_hold",
    "closed_details.original_questions",
    "closed_details.reason",
    "comment.comment_id",
    "comment.creation_date",
    "comment.edited",
    "comment.owner",
    "comment.post_id",
    "comment.reply_to_user",
    "comment.score",
    "error.description",
    "error.error_id",
    "error.error_name",
    "event.creation_date",
    "event.event_id",
    "event.event_type",
    "filter.filter",
    "filter.filter_type",
    "filter.included_fields",
    "flag_option.count",
    "flag_option.description",
    "flag_option.has_flagged",
    "flag_option.option_id",
    "flag_option.requires_comment",
    "flag_option.requires_question_id",
    "flag_option.requires_site",
    "flag_option.sub_options",
    "flag_option.title",
    "inbox_item.answer_id",
    "inbox_item.comment_id",
    "inbox_item.creation_date",
    "inbox_item.is_unread",
    "inbox_item.item_type",
    "inbox_item.link",
    "inbox_item.question_id",
    "inbox_item.site",
    "inbox_item.title",
    "info.answers_per_minute",
    "info.api_revision",
    "info.badges_per_minute",
    "info.new_active_users",
    "info.questions_per_minute",
    "info.total_accepted",
    "info.total_answers",
    "info.total_badges",
    "info.total_comments",
    "info.total_questions",
    "info.total_unanswered",
    "info.total_users",
    "info.total_votes",
    "migration_info.on_date",
    "migration_info.other_site",
    "migration_info.question_id",
    "network_user.account_id",
    "network_user.answer_count",
    "network_user.badge_counts",
    "network_user.creation_date",
    "network_user.last_access_date",
    "network_user.question_count",
    "network_user.reputation",
    "network_user.site_name",
    "network_user.site_url",
    "network_user.user_id",
    "notice.body",
    "notice.creation_date",
    "notice.owner_user_id",
    "notification.body",
    "notification.creation_date",
    "notification.is_unread",
    "notification.notification_type",
    "notification.post_id",
    "notification.site",
    "original_question.accepted_answer_id",
    "original_question.answer_count",
    "original_question.question_id",
    "original_question.title",
    "post.creation_date",
    "post.last_activity_date",
    "post.last_edit_date",
    "post.link",
    "post.owner",
    "post.post_id",
    "post.post_type",
    "post.score",
    "privilege.description",
    "privilege.reputation",
    "privilege.short_description",
    "question.accepted_answer_id",
    "question.answer_count",
    "question.bounty_amount",
    "question.bounty_closes_date",
    "question.closed_date",
    "question.closed_reason",
    "question.community_owned_date",
    "question.creation_date",
    "question.is_answered",
    "question.last_activity_date",
    "question.last_edit_date",
    "question.link",
    "question.locked_date",
    "question.migrated_from",
    "question.migrated_to",
    "question.owner",
    "question.protected_date",
    "question.question_id",
    "question.score",
    "question.tags",
    "question.title",
    "question.view_count",
    "question_timeline.comment_id",
    "question_timeline.creation_date",
    "question_timeline.down_vote_count",
    "question_timeline.owner",
    "question_timeline.post_id",
    "question_timeline.question_id",
    "question_timeline.revision_guid",
    "question_timeline.timeline_type",
    "question_timeline.up_vote_count",
    "question_timeline.user",
    "related_site.api_site_parameter",
    "related_site.name",
    "related_site.relation",
    "related_site.site_url",
    "reputation.on_date",
    "reputation.post_id",
    "reputation.post_type",
    "reputation.reputation_change",
    "reputation.user_id",
    "reputation.vote_type",
    "reputation_history.creation_date",
    "reputation_history.post_id",
    "reputation_history.reputation_change",
    "reputation_history.reputation_history_type",
    "reputation_history.user_id",
    "revision.comment",
    "revision.creation_date",
    "revision.is_rollback",
    "revision.last_tags",
    "revision.last_title",
    "revision.post_id",
    "revision.post_type",
    "revision.revision_guid",
    "revision.revision_number",
    "revision.revision_type",
    "revision.set_community_wiki",
    "revision.tags",
    "revision.title",
    "revision.user",
    "search_excerpt.answer_count",
    "search_excerpt.answer_id",
    "search_excerpt.body",
    "search_excerpt.creation_date",
    "search_excerpt.excerpt",
    "search_excerpt.is_accepted",
    "search_excerpt.is_answered",
    "search_excerpt.item_type",
    "search_excerpt.last_activity_date",
    "search_excerpt.question_id",
    "search_excerpt.score",
    "search_excerpt.tags",
    "search_excerpt.title",
    "shallow_user.accept_rate",
    "shallow_user.display_name",
    "shallow_user.link",
    "shallow_user.profile_image",
    "shallow_user.reputation",
    "shallow_user.user_id",
    "shallow_user.user_type",
    "site.aliases",
    "site.api_site_parameter",
    "site.audience",
    "site.closed_beta_date",
    "site.favicon_url",
    "site.high_resolution_icon_url",
    "site.icon_url",
    "site.launch_date",
    "site.logo_url",
    "site.markdown_extensions",
    "site.name",
    "site.open_beta_date",
    "site.related_sites",
    "site.site_state",
    "site.site_type",
    "site.site_url",
    "site.styling",
    "site.twitter_account",
    "styling.link_color",
    "styling.tag_background_color",
    "styling.tag_foreground_color",
    "suggested_edit.approval_date",
    "suggested_edit.comment",
    "suggested_edit.creation_date",
    "suggested_edit.post_id",
    "suggested_edit.post_type",
    "suggested_edit.proposing_user",
    "suggested_edit.rejection_date",
    "suggested_edit.suggested_edit_id",
    "suggested_edit.tags",
    "suggested_edit.title",
    "tag.count",
    "tag.has_synonyms",
    "tag.is_moderator_only",
    "tag.is_required",
    "tag.name",
    "tag.user_id",
    "tag_score.post_count",
    "tag_score.score",
    "tag_score.user",
    "tag_synonym.applied_count",
    "tag_synonym.creation_date",
    "tag_synonym.from_tag",
    "tag_synonym.last_applied_date",
    "tag_synonym.to_tag",
    "tag_wiki.body_last_edit_date",
    "tag_wiki.excerpt",
    "tag_wiki.excerpt_last_edit_date",
    "tag_wiki.tag_name",
    "top_tag.answer_count",
    "top_tag.answer_score",
    "top_tag.question_count",
    "top_tag.question_score",
    "top_tag.tag_name",
    "top_tag.user_id",
    "user.accept_rate",
    "user.account_id",
    "user.age",
    "user.badge_counts",
    "user.creation_date",
    "user.display_name",
    "user.is_employee",
    "user.last_access_date",
    "user.last_modified_date",
    "user.link",
    "user.location",
    "user.profile_image",
    "user.reputation",
    "user.reputation_change_day",
    "user.reputation_change_month",
    "user.reputation_change_quarter",
    "user.reputation_change_week",
    "user.reputation_change_year",
    "user.timed_penalty_date",
    "user.user_id",
    "user.user_type",
    "user.website_url",
    "user_timeline.badge_id",
    "user_timeline.comment_id",
    "user_timeline.creation_date",
    "user_timeline.detail",
    "user_timeline.post_id",
    "user_timeline.post_type",
    "user_timeline.suggested_edit_id",
    "user_timeline.timeline_type",
    "user_timeline.title",
    "user_timeline.user_id",
    "write_permission.can_add",
    "write_permission.can_delete",
    "write_permission.can_edit",
    "write_permission.max_daily_actions",
    "write_permission.min_seconds_between_actions",
    "write_permission.object_type",
    "write_permission.user_id"
  ],
  "filter_type": "safe"
};

jQuery.ajax 
(
  {
  url: "https://api.stackexchange.com/2.1/filters/create",
  type: "POST",
  data: JSON.stringify(bar),
  dataType: "json",
  contentType: "application/json; charset=utf-8",
  success: foo 
  }
);  

参考文献

于 2013-10-10T01:10:08.650 に答える