Need help with cross domain POST using .ajax or json(p) grabbing and formatting returned data
Im trying to validate a form (easy) and POST it to a third party WCF service. I am able to validate and POST data to the service, but its returned data (in table format) keeps opening in a blank page with their url in the browser address bar. Can't have that, I need to grab the returned data and .append it to a div on my page. Here is what I have that FAILS
<script type="text/javascript">
$(document).click(function() {
//cancel form
$.validator.methods.equal = function(value, element, param) {
return value == param;
};
var validator = $("#Cancel").bind("invalid-form.validate", function() {
$("#summaryCS").html("Your form contains " + validator.numberOfInvalids() + " error(s), please fix.");
}).validate({
//debug: true,
errorElement: "em",
errorContainer: $("#summaryCS"),
errorPlacement: function(error, element) {
error.appendTo( element.parent("li"));
},
success: function(label) {
label.text("ok!").addClass("success");
},
submitHandler: function(form) {
$.ajax({
url: form.action,
type: "post",
data: data,
dataType: "jsonp",
success: function(data) {
var answer = $(data).find("td:eq(4)").text();
if (answer==="TRUE") {
$("#resetPassword").remove();
$("#resetSuccess").fadeIn("slow");
} else {
$("#resetPassword").remove();
$("#resetError").fadeIn("slow");
}
}
});
return false;
},
rules: {
AccountUserID: {
required: true,
minlength: 5
},
EmailAddress: {
required: true,
email: true
},
Reason: {
required:true
}
},
messages: {
AccountUserID: {
required: "Please Enter Your User ID",
minlength: "Your User ID Must be at Least 5 Characters"
},
EmailAddress: {
required: "Please enter your email address",
email: "Please enter a valid email address"
},
Reason: {
required: "Please select a reason for cancelling"
}
}
});
//$(document).ajaxError(function(e, xhr, settings, exception) {
//alert('error in: ' + settings.url + ' \\n'+'error:\\n' + exception);
//});
});
</script>
form action ="https://xxxxx/xxxxx/POST.svc/Cancel" I have been searching on google for a week, all solutions dont seem to work for me or require advanced PROXY workarounds. Is there a simple way to grab this data? Please help!