I have a problem to posting data to WebaPi controller using Jquery ajax in html page .. when i test through fiddler it's coneected and working fine , but when i try to using Ajax it give error only..
here is my sample code ..
var bookData = {
"CurrentCompany": "BizSight Sample Product Company",
"CompanyName": CompanyName,
"LegalName": "Biztech",
"Address1": Address1,
"Address2": Address2,
"City": City,
"State": State,
"Phone": Phone,
"ZipCode": ZipCode,
"Fax": Fax,
"Email": Email,
"Website": Website,
"CountryID": 1,
"federalTaxID": 1,
"CurrentUser": CurrentUser,
"BusinessType": BusinessType,
"CurrentFiscalYear": Jsondate
};
$.ajax({
type: "POST",
cache: false,
url: "http://77b2130d5c3446eea4e4210c51529230.cloudapp.net:8080/Create/",
data: JSON.stringify(bookData),
contentType: "application/json; charset=utf-8",
dataType: "json",
processData: true,
success: function (data, status, jqXHR) {
var result = JSON.stringify(data);
$("#loading").show();
alert("success..." + result);
},
error: function (xhr) {
$("#loading").show();
alert("Test3:" + xhr.statusText);
}
});
When i post data from html and check fiddler it give message like below image
am i missing anything in this code..? fiddler it self it's working but frmo html page not working .. can you please help me how to resolve and achieve this
My Api class `
public class CreateController : ApiController
{
public static string CompanyName = " ";
public static string con;
public static string sqlConnection;
public static string DatabaseName;
string TrustedConnection = "Yes";
string DBServer = " ";
string FilePath = null;
string testFirstline = " ";
//clsLog objLog = new clsLog();
bool isSuccess = false;
public string Post(DatabaseCls cls)
{
string ReturnMessage = "Success";
// ReturnMessage = "Hello " + id + "_" + parameter1 + "_" + parameter2 + "_" + parameter3 + "_" + parameter4 + "_" + parameter5 + "_" + parameter6 + "_" + parameter7 + "_" + parameter8 + "_" + parameter9 + "_" + parameter10 + "_" + parameter11 + "_" + parameter12 + "_" + parameter13 + "_" + parameter14 + "_" + parameter15;
return ReturnMessage;
}}
Thanks Victor .A
data : JSON.stringify(bookData),