How can you create an HTTP POST request in ActionScript 1? - actionscript-1

I have a text field that I'd like to support an arbitrary amount of text in. Right now the text is sent through an XML object request using GET. I'd like to use POST to send the data back to the server. Are there any good options in ActionScript 1?

You want to use the LoadVars object and assign values to keys you create as you go so:
obj.id=myId;
obj.status = myStatusId;
obj.sendAndLoad(url, responseVarThatYouSetupToHandleOnLoadEvent, "POST");

Related

Getting the value of a particular cell with AJAX

My goal is very simple and I would guess it is a very common goal among web developers.
I am creating a Rails (5.1) application, and I simply want to use AJAX to get the value of a specific cell in a specific row of a specific table in my database (later I am going to use that value to highlight some text on the current page in the user's browser).
I have not been able to find any documentation online explaining how to do this. As I said, it seems like a basic task to ask of jquery and ajax, so I'm confused as to why I'm having so much trouble figuring it out.
For concreteness, say I have a table called 'animals', and I want to get the value of the column 'species' for the animal with 'id' = 99.
How can I construct an AJAX call to query the database for the value of 'species' for the 'animal' with 'id' = 99 .
Though some DBs provide a REST API, what we commonly do is define a route in the app to pull and return data from the DB.
So:
Add a route
Add a controller/action for that route
In that action, fetch the data from the DB and render it in your preferred format
On the client-side, make the AJAX call to that controller/action and do something with the response.

How convert blob type in to data url using spring MVC?

I'm creating a Spring MVC application. I also have a dataTable in the MySQL database. Inside the database, there is a table, and inside the table consist of several columns. One of the columns has type data "LONGBLOB" (the name of the column is file_data)
The picture is the content of 1 "file_data".
1. How to convert the file_data which has longblob type to data URL?
There are some tutorials/discussions about this topic on the internet, but mostly using javascript. I have not got the idea how to convert it by using spring MVC.
Actually you can use javascript to the blob data. The idea is, try to show the data from your controller into your html/jsp file (frontend). And then, try to get the content, for example you put the data inside tag div with certain class or id.
After that, try to get it inside javascript, for example var blob = document.getElementById('<you id/class name>').innerHTML;
var data = new Blob([blob], {type: 'text/csv;charset=utf-8;'});
URLdata = window.URL.createObjectURL(data);

How to insert json encoded inputs into foreign related tables

I am creating functionalities in yii+extjs. My client side is desighned in extjs and server side is in yii framework.
I am having two tables as
Poll Option
-pollId -optionId
-PollQuestion -option
-pollId
Now through poll creation form which will be in extjs,Question and its related option gets send to server in json format. So in yii framework,in actionCreate function will get input as-
$json='{"pollId":1,"PollQuestion":"Who is the best
cricketer","option":"ABC","option":"DEF","option":"XYZ"}'
$obj=json_decode($json);
During creation of poll,user can enter any number of options.So number of options can be anything.
i am creating above functionality in Pollcontroller.
So this newly created question gets inserted into Poll table as=
$model=new Poll();
$model->pollId=$obj->pollId;
$model->PollQuestion=$obj->PollQuestion;
Now i want to put all these new options in option table with same pollId. So how to add all these options in option table? Please help me
I would start by modifying the JSON so the options are a separate JSON within the pollquestion JSON.
Something like this...
$json='{"pollId": 1,"PollQuestion": "Who is the best cricketer",
"options":{[{"value":"ABC"},{"name": "DEF"},{"name": "XYZ"}]}';
That way when you decode it with json_decode you'll get an options array which you can go through and add each of the elements in that array in the options array.
for($i=0; $i<sizeof($obj['options']);$i++){
//Add to table logic here
}

ServiceNow - JSON Web Service, display related tables

I'm working on a C# program that retrieves data from a ServiceNow database and converts that data into C# .NET objects. I'm using the JSON Web Service to return my data in JSON format.
What I want to achieve is as follows: If there is a relational mapping between a value (for
example: I have a table called Company, where CEO is not a TEXT field but an sys_id to a Employee Table) I want to be able to output that data not with an sys_id (or just displaying the name property by using the 'displayvariable' parameter) but by an object displayed in JSON.
This means that the value of a property should be an object in JSON instead of just a single value.
A few examples:
// I don't want the JSON like this
{"Company":{"CEO":"b181e841c9212c008aeb36850331fab2"}}
// Or by displaying the name of the sys_id table
{"Company":{"CEO":"James Henderson" }}
// I want the data as follows, so I can have all the data I need inside a single JSON record.
{"Company":{"CEO":{"name":"James Henderson", "age":34, "sex":"male", "office":"SBN Left Floor 23"}}}
From reading the documentation I couldn't find anything in the JSON Web Service that allowed me to display the information like this nor
find any other alternative. It should have something to do with joining the tables and displaying it all in the right format.
I have been using SNC for almost three years and have not found you can automatically join tables in a web service. Your best option would be to use a scripted web service which possibly takes a query parameter and table parameter. Then you can json serialized your result as you see fit.
Or, another option would be to generate a new processor that will traverse the GlideRecord object. The ?JSON parameter you pass in to the URL is merely a flag to pass your request to a particular processor. Unfortunately the OOB one I believe is a Java class not a JS script, so you would need to write a script much like I mentioned earlier to traverse the object path serializing the object graph as far down as your want to go.

GET and POST values in the same link

I want something like this:
link
GET and 2x POST in hyperlink. How can I do that? Nothing wants to work
I have a GET array in PHP and I want to generate a link which leads to the correct url to give me those GET variables.
You can't have 2 GET variables with the same name. You can arrange them into an array as follows:
link
Just for clarification, this is still a GET request, links cannot normally produce a POST request, nor you should try to achieve that not-normally.
EDIT: To answer OP's calrification.
If you have a $_GET array, and you want to generate a link to get you there, you can use http_build_query()
I don't think you understand what GET and POST means in the HTTP world. Any items you put on a query string of a URL are GET parameters, you can't have 2 with the same name. POST parameters are sent as a part of the request, not as a query string on the URL.
GET and POST are http operations.
Sending values by using the ? as a separator in the url is different but related. eg:
foo.com/page.php?val1=1&val2=2
The values are called Query String values.
For GET operations, values are sent as a query string values. For POST operations, the values are sent in the body of the POST request. This is why POST must be used when a lot of data is being sent to the server. (Query strings have a maximum length, HTTP requests do not.)
You can do a POST operation to a url that includes query string values. This is more common with Ajax requests but can be done in a form as well. Just set the action url to something like index.php?val1=1&val2=2 the form's (additional) values will be sent as the http body. Remember to set method="post" in the form.
Note that you will need to create the query string yourself in this example, including escaping it properly.
Repeating value names in the query string values
Usually this causes both values to be sent, but the server overwrites the variable and ends up only presenting the last one to the client software.
So if you use a url such as
<a href="http://localhost/index.php?get=abc&post=cde&post=efg">
// It will be decoded by php and most server-side frameworks as
set get to abc
set post to cde
set post to efg
Result: 2 variables, get and post
There is nothing in the HTTP standard that says you can't send two query string params with the same name. However, you won't be able to use $_GET to retrieve these values; $_GET will pick up the last one. Instead, you'll have to manually parse $_SERVER['QUERY_STRING']. It's not that hard and I've done it a number of times when PHP has to handle a URL pattern generated by a third-party tool. If you're feeling really fancy you can have your query-string parse routine generate a $_GET member as an array if more than one instance of that member is encountered.