Edit: I understand that its probably easiest to use jQuery's built in ajax function here, but my question now is about the names that the form is using for its fields. This is a var_dump of what the form usually submits using test values. It seems to be randomly generating the form names which makes this problematic.
array (size=10)
'__CSRFToken__' => string '3bc67b3ea7645150d346c3db476c53a94ceee80e' (length=40)
'a' => string 'open' (length=4)
'topicId' => string '12' (length=2)
'4d46ff92be4bf2f9' => string 'test' (length=4)
'b6679eba951ccafb' => string 'test' (length=4)
'de756c0f51c9b255' => string '' (length=0)
'de756c0f51c9b255-ext' => string '' (length=0)
'099ed5bd56c915a1' => string 'test' (length=4)
'message' => string 'Test' (length=4)
'draft_id' => string '4' (length=1)
On one of my web pages has users enter information to fill a ticket form. I am using osTicket to manage them but I am collecting the information on a separate page for certain reasons. Suppose I have all of the information stored in a Javascript object,
var ticket = {
name : "John Snow",
email : "test@gmail.com",
summary: "xxx",
body: "xxxx"
};
for example, how could I go about getting that information to the form on the other page ( picture below ) and submit it?
You could use ajax with something like this:
var xhReq = new XMLHttpRequest();
xhReq.open("GET", "page.php?name=name&emailemail&etc...", false);
xhReq.send(null);
var serverResponse = xhReq.responseText;
alert(serverResponse); // Shows "15"
You should read this for a better explanation AJAX
You can submit form by various methods by using html form tag ,jquery etc.I m giving example with jquery. Script:
$('#submitButn').click(function () {
$.ajax({
url: "/Home/Index", //url for your page,
type: "POST",
data: dataToPost //you data which u want to post
success: function (data, status) {
},
error: function (xhr, desc, err) {
alert("error");
},
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.