Issue in save values by Json (WCF) - javascript

I have the following Code in Json :
$.ajax({
type: "POST",
data: JSON.stringify(params),
contentType: "application/json; charset=utf-8",
url: AppCOJS.getBaseURL() + '/hcis/license-services/SE.TCC.CLU.Services.Transactional.ServiceManagementRequestInfoDetails.svc/SaveCustomerClearanceInformation',
dataType: "json",
async: true,
complete: SaveCustomerClearanceInformationCompleted
});
That code for adding values to table in DataBase sql server ,I submitte the request and I see the result data which is returned by WCF service in google chrome debugging window .
But when i go to the table i didn't see any values added to it ?
When I execute the request by Console Application ,It is working fine and the values are added to the table .
What is the problem ?

Related

send json data to another url - after you've got it back from my own url

This is how the json I get from my page send when I clicked post, I throw a different URL.
That piece of data should like to come to look like this:
api.quickpay.net/subscriptions?currency=dkk&order_id=testworld&description=MB: 6-testworld
But when I get my json back watching it like this:
{"Prices":220,"HiddenIdMedlemskab":6,"ordre_id":"6-8315042016","currency":"DKK","description":"MB: 6-8315042016"}
The json should I have shed into a url that I added earlier.
My jquery code looks like this:
$.ajax({
type: 'post',
url: '/Medlem/medlemskabet',
dataType: 'json',
data: JSON.stringify(requestData),
contentType: 'application/json; charset=utf-8',
async: true,
processData: false
});
Over on my url /Medlem/medlemskabet
That gets the dates that I need for my json to specify package price orderid etc
So my question is How do I tag my json about throwing it over to the api URL and throws it into their system.
I've built since the MVC C #
You can pass the JSON object as an argument to $.get(), and jQuery will convert the properties into URL parameters.
$.ajax({
type: 'post',
url: '/Medlem/medlemskabet',
dataType: 'json',
data: JSON.stringify(requestData),
contentType: 'application/json; charset=utf-8',
async: true,
processData: false,
success: function(response) {
$.get('api.quickpay.net/subscriptions', response);
}
});

Javascript vb2013 calling url removing host name

I am new to serious javascript programming, Working my way up in the world to HTML5 and I have gone round and round.
The address works in a browser so I know its there, but when I go to debug I get a 404 error from the following javascript code
function loadTotalLabels() {
//get json data
var jsonData = JSON.stringify({ "args": "" });
$.ajax({
type: "POST",
async: false,
cache: false,
url:"http://localhost:52594/Service1.svc/getTest",
data: jsonData,
contentType: "application/json; charset=utf-8",
dataType: "json", // dataType is json format
success: onTotalsSuccess_,
error: OnErrorCall_
});
}
When I look at the error it tells me that it can not find Service1.svc/getTest
If I remove the Port number and put the project name in (http://localhost/prsTest/service1.svc/getTest which is running on my local IIS), it works fine (throws a Network error, but one error at a time).
So, can anyone tell me how to get the Javascript to use the "localhost + port number"? I have tried location.host and that did not work. Or tell me where to look, as I have not found anything on this item.

jQuery Ajax POST JSON issue

I'm trying to pass a JavaScript array into a PHP script to then be put into a database but I'm having issues. I have used JSON.stringify on the array before sending. The request seems to work in that when stepping through the code debugging the php page is called but no data is passed into the POST global. I'm sure its something amateurish that I've missed but I'm struggling. This is the code:-
$.ajax({
type: "POST",
datatype: "json",
url: "processdraw.php",
data: {
json: pDrawnTeams
},
contentType: "application/json; charset=utf-8",
success: alert('worked')
})
If you are not getting any error in your javascript, make sure that you are getting that parameter like this in your php target file:
$myJSON = $_POST['json']; // ['parameter name']
after that you will need to decode that json
$myData = json_decode($myJSON, true) // true is for retrieving as an array

Google calendar returns not a valid json file

We are making a website with AngularJS. We need the google calendar events.
I try to load the data from a Google Calandar.
here you can find the json file: http://www.google.com/calendar/feeds/nmk97b3l07ncb9f9h5ap5ffo2c#group.calendar.google.com/public/full?alt=json-in-script&callback=insertAgenda&orderby=starttime&max-results=15&singleevents=true&sortorder=ascending&futureevents=true
But Angulair does not recognize it as a json file.
Is there a way to get this as json file?
insertAgenda is the jsonp-callback-parameter.
Try this:
var url = 'http://www.google.com/calendar/feeds/nmk97b3l07ncb9f9h5ap5ffo2c#group.calendar.google.com/public/full?alt=json-in-script&callback=insertAgenda&orderby=starttime&max-results=15&singleevents=true&sortorder=ascending&futureevents=true';
$.ajax({
type: 'GET',
url: url,
async: false,
jsonpCallback: 'insertAgenda', //The callback parameter in Google Calendar response
contentType: "application/json",
dataType: 'jsonp',
success: function(json) {
console.dir(json);
}
});
DEMO

write JSON data in sql

Being a newbie and working on a web application i am stuck at passing a JSON object in Javascript file to a SQL database. I have no clue on how to proceed further. I have created a SQL table with this addon of mozilla https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/
Any suggestions on how to perform this?
If you want to pass JSON object to database then you can use "$.ajax".
Sample Code:
$.ajax({
type: "POST",
url: "mypage.aspx/mystaticmethod",
data: "{'fistcolumn':'firstvalue','secondcolumn':'secondvalue'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
});
}
});
At:
data: "{'fistcolumn':'firstvalue','secondcolumn':'secondvalue'}",
you can directly send your JSON object and at code behind you will get all values.
protected static void mystaticmethod(string firstcolumn, string secondcolumn)

Categories

Resources