AJAX

12K

Solutions

7K

Contributors

Asynchronous JavaScript and XML (AJAX) is a group of interrelated Web development techniques used on the client-side to create asynchronous Web applications. With AJAX, web applications can send data to and retrieve from a server asynchronously (in the background) without interfering with the display and behavior of the existing page. HTML and CSS can be used in combination to mark up and style information. The Document Object Model (DOM) is accessed with JavaScript to dynamically display and allow interaction with the information presented.

Share tech news, updates, or what's on your mind.

Sign up to Post

Hi, is it possible to sort xml data in a classic asp page using AJAX and querystrings??

xml code

<?xml version="1.0" standalone="yes"?>
<DocumentElement>
<Data>
<EnsembleID>23331</EnsembleID>
<BookCode>NWP-MV</BookCode>
<Issue>Aeon Financial 2019</Issue>
<LongBLPTicker>QZ3838484 Corp</LongBLPTicker>
<ShortBLPTicker>8570 JT Equity</ShortBLPTicker>
<LongPos></LongPos>
<StubPos>600000000</StubPos>
<SIV>0.927</SIV>
<Parity>91.95</Parity>
<Premium>0.173</Premium>
<IV>99.23</IV>
<LongPx>107.81</LongPx>
<PxChg>0.05</PxChg>
<TheoChg>0.03753</TheoChg>
<StubPrice>8.59</StubPrice>
<ShPxChgPer>0.001277</ShPxChgPer>
<SLH>0.009</SLH>
<CurDelta>0.32</CurDelta>
<ImpDelta>0.444</ImpDelta>
<TheoDelta>0.417</TheoDelta>
<FutHdg1>-14.13</FutHdg1>
<ImpVolCB>0.242</ImpVolCB>
<ImpVolStub>0.242</ImpVolStub>
<V90D>0.198</V90D>
<DPnL>0.4</DPnL>
<WPnL>3</WPnL>
<MPnL>1.2</MPnL>
<YPnL>-4.9</YPnL>
<NetPnL>16.8</NetPnL>
<DayTE>-0.1647</DayTE>
</Data>

Open in new window




Page code...


<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Summary</title>
<style>
table {
    border-collapse: collapse;
    width: 100%;
}

th, td {
	font-family:Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;
    text-align: left;
    padding: 8px;
}
tr:nth-child(odd){
	font-family:Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;
	font-size:10px;
	background-color: #eef6ff
	}
tr:nth-child(even){
	font-family:Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;
	font-size:10px;
	

Open in new window

0
New feature and membership benefit!
LVL 10
New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

I have something like below. And all I need is to get xml string
And then save as new xml

<products>
<product>a</producf>
<product>b</product>
</products>

Return xml file and get just product a.
0
I have a jQuery autocomplete where it is populated a JSON file with a label and a value.

Can someone write a event handler in my script that will call a function and alert the value when it is selected from the autocomplete?

$(document).ready(function() {
    $('#rates-input').autocomplete({
        source: "../js/selections.php"
    });
});

Open in new window

0
How do you setup a wait wheel animation while a file is loading in Visual Studio?

Thanks,

Dan
0
i have asp.net/c# web form project and on code behind we use about of the [webmethod]. And I want to use ajax updatepanel
to prevent auto fresh when the asp.net onclick button is clicked.

However, my programmer told me that ajax updatepanel won't work in this case. Please share with me if this is truth.

Thanks
0
I've got a problem that needs solving and it involves the function that you see below. I'm trying to get to a place where I can understand every line of the code and I would appreciate some confirmation on what I THINK I understand. In other instances, I'm just plain stuck.

Here's what I've got:

    function filterInit(){ // Init means I'm starting this as soon as the page initializes
        $('select').material_select(); // I don't know what "material_select" means

        $.ajax({ //this is what's happening when the user clicks on the "select" - you've got an AJAX request being triggered
            'url': '/admin/library/get-tags', // the URL of the code that's returning data
            'data': {
                'filtered': true // don't know what the significance of this is
            },
            'dataType': 'JSON', // data type is JSON
            'success': function(resp){ // if there's data being returned, then do the following
                // remove everything but the default option since it acts as the label for material_select()
                $('#filter-tags option:not([value=""])').remove(); // if the value is blank, remove it
                $('#filter-tags-default option:not([value=""])').remove(); //if the value is blank, remove it

                // add the tags as options
                for (var i in resp.data) { //populating the select with options, but I don't understand the next two lines
                    var $select …
0
The link:

http://www.kingislandrenewableenergy.com.au/kiapp-dashboard/dashboard.html

produces a chart that seems to be constantly updating. I would like to do something similar.

I used a sniffer - HTTP Analyzer V7 - to try and understand how the requests are made so that data is sent to the web page. However, I have not been able to find the GET or POST that should be periodically getting more data. I am lost.

How does this thing work?
0
I have setup a page (using php) on our intranet which uses ajax to record background data on another website https://website.com.
The data that that is passed via ajax is being recorded, but the response is not being received.

The ajax call is as follows:
$.ajax({ // create an AJAX call...
      url: 'https://www.website.com/card.php?me=1482', // the file to call
      success: function(response) { // on success..
                $('#cardinfo').html(response); // update the DIV
      }
});

The div element does exist and the id is correct.

Assistance appreciated.
1
I essentially have 2 forms on one page. Each has some input controls and a button. I want to validate the controls relative to the button, but when using basic bootstrap validation techniques, both buttons validate the entire page.

How do I break up the forms and only validate the controls relative to the 2 buttons?

For example...

 <div class="col-lg-12">
    <h2><u>Daily Schedule</u></h2>
    

    <div class="col-md-3">
    <label for="heard2">Enabled?</label>
    <div class="form-group">
    <asp:DropDownList ID="ddlDaily" runat="server" class="form-control"></asp:DropDownList>
    </div>
    </div>
    
                    <div class='col-md-3'>
                     <label for="heard">Start Date/Time <i>(will repeat daily)</i></label>
                    <div class="form-group">
                        <div class='input-group date' id='myDatepicker'>
                            <asp:TextBox ID="tbDDT" runat="server" class="form-control"></asp:TextBox>
                            <span class="input-group-addon">
                               <span class="glyphicon glyphicon-calendar"></span>
                            </span>
                        </div>
                    </div>
                    </div>
   
    
    </div>
    <div class="col-md-3">&nbsp;&nbsp;&nbsp;<asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" class="btn btn-primary" /><br /><br /><br /></div>

Open in new window


How would I only validate the fields above when clicking the button above, ignoring anything else that might be on this page?
0
I have implemented a cascading drop-down with two drop down boxes and it works.  The problem is that the drop downs don't clear out when a new selection is made, so it grows with current and previous values.  I think it's because my array does not clear out.  I tried doing used.length=0 but that did not work.

Any help would be appreciated.


<tr>
                <td>Priority</td>
                <td>
                                <select id="priority">
                                </select>
                </td>
  </tr>
<tr>
                <td>Station</td>
                <td>
                                <select id="station">
                                </select>
                </td>
  </tr>

$(document).ready(function() {                
                                                      
         fillDropDown('Project Module');
                     
});


function fillDropDown(list, stVal) {

                if (list == "Project Module") {
                                //The internal name for 'priority' is 'field13'
                                var endPointUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbyTitle('Project Module')/items?$select=field13";
                }else{
                                if (stVal.length == 1) {
                                                stVal = "0"+stVal;
                                }
                                var endPointUrl = _spPageContextInfo.webAbsoluteUrl + 

Open in new window

0
Tech or Treat!
LVL 10
Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Iam new to MVC,.On Home page I have a Html form (Index.cshtml) with  2 drop down displaying city from and city to.  i want to bind html grid on other view (Search.cshtml) depending upon my selection using Ajax MVC 5 iam using stored procedure taking 2 parameters, city from and city to. Iam also using EF 6 Database First .
I do not know where iam Missing. Also Getting Null Parameters. Please resolve my issue.

HomeController.cs

namespace DropinCabs.Controllers
{
    public class HomeController : Controller
    {
        // GET: Home
        DropinEntities _cNx = new DropinEntities();
        [HttpGet]
        public ActionResult Index()
        {
            var List = _cNx.GetCities().ToList();
            SelectList list = new SelectList(List, "CityID", "CityName");
            ViewBag.CityList = list;
            return View();
        }
       
        public JsonResult Search(int? CityFrom, int? CityTo)
        {
           
            return Json(_cNx.Getsearchresult(CityFrom, CityTo), JsonRequestBehavior.AllowGet);
        }

    }

}

Search.cshtml
@section Scripts
{
    <script type="text/javascript">

        (function ($) {
            $.ajax({
                url: '@Url.Action("Search")' + Cityrom + CityTo,
                type: "POST",
                contentType: "application/json;charset=utf-8",
                dataType: "json",
                success: function (data)
                {
                    var items…
0
For security reason I store client files outside of root directory. To view files I use html form generated by Ajax. There is no problem to use that form to upload files to the server. The problem is to get it back and display on a generated form. All other information I can get by PHP file using XML header and display it on a form. To display downloaded file in PHP I can use readfile($uploaddir."file_name") function. But how can I pass downloaded file to my generated html form?
0
I have an AJAX Call that runs a function and it all works,  However, it does it does not return the Success message.  My code.
<html>
 <form id="unjoin" method="post">
                    <input id="email" name="email" type="hidden" value="<?php echo $unsub; ?>" />
                <input type="submit" name="submit" id="submit" value="Click Here To Unsubscribe">
                </form>
            </div>
            <div id="unsubscribe_bye" class="unsubscribe_bye">

            </div>

<script>
<script>
    $(document).ready(function () {
        $("#unjoin").on('submit', function (e) {
            e.preventDefault();
        });
        $("#submit").click(function () {

            $.ajax({
                url: 'includes/unsubscribe.php',
                data: $("#unjoin").serialize(),
                type: 'POST',
                dataType: 'JSON',
                success: function (response) {
                    $("#unsubscribe_bye").html(response.success);
                    console.log(response);
                    $("#unjoin")[0].reset();
                }
            });

        });
    });
</script>

<?php
$success = "";
$return = new stdClass;

$e = $_POST['email'];

$sql = "SELECT subscriber_id AS subscriber_id FROM test_table WHERE email = :email";

$pdos = $pdo->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));

$pdos->bindParam(':email', $e, PDO::PARAM_STR);

try {
    $pdos->execute();
    $rows = $pdos->fetch();
    $num = 

Open in new window

0
Hello Experts,

This post is more or less to pick your brain about things/ideas I should implement into my current system. Basically, the only requirement for my system was turn my employer's paper-based car seat rental program into a paperless system.

Here are screenshots of my system:

Index.php
Index.php
Rental-form.php
Rental-form.php
Rent-success.pdf

(See attached PDF)

Return-form.php
return-form.php
Right now, the system does the following:
  1. Presents the user (coworker) with a choice to either rent or return a car seat;
  2. Provides an inventory of any available seats (from a MySQL database);
  3. Generates a PDF version of our current rental agreement using FPDF;
  4. Emails the generated PDF to the renter and another department in my office (not implemented yet); and
  5. Presents the user with an HTML table in order to return any rented car/booster seats.

Being that I am a hobbyist php programmer, I am kind of in the dark when it comes to certain things. My career has nothing to do with programming, either. I enjoy PHP and took this task upon myself for fun.
rent-success.pdf
0
I am trying to do something similar to the app specs below.  I'm looking for a sample.  I thought I would use Asp.net Core MVC,  Ajax and SQL server.  I'm looking for a sample that can show me each step.

It's pretty simple.
1. My app has a form with 4 fields. (Vin, Make, Model, Year)
2. I input Vin in field 1 (Vin)
3. I GET from a third party Rest API JSON by passing the Vin to a URI string. The string will pass Vin I input and an API key
4. The API returns (Make, Model, Year)
5. I want to fill the additional form fields with (Make, Model, Year)
6. Finally, I want to save all fields (Vin, Make, Model, Year), to my Database.

I have been searching for an example similar.  I did find the Weather app example, but it's not complete.  It's just part of it.
Weather example: https://www.codeproject.com/Articles/1180283/How-to-Implement-OpenWeatherMap-API-in-ASP-NET-MVC
0
Hello,

First of all sorry for my bad english! :)
I would like to make a keyword suggester with elasticsearch and symfony3.
My users want to publish a post. When they type the title of the post, it launch an ajax call at the 'focusout' of the title field.
This ajax call analyse the text and split the string at withespace. Then it launch a elastic query for each substring.
Its working but its a lot of request for nothing...
I would like to make a full text search and elastic gave me the keywords he found in the text.
For exemple:
Title: I would ike to drive a bike in the city to go see the boat.
Elastic give : 'bike', 'city', and 'boat'

Experts Exchange make this autossuggest keyword with the title.

If someone can help me :)

Thank a lot,
best regards.
Quentin,
0
I have the javascript where I am trying to do a simple show / hide of the div. but it does not work . please advice

http://jsfiddle.net/p51dytok/4/
0
Hello Experts,

Using PHP, what is the best way to verify the user’s information, modify the information if necessary, and then process their information?

NOTE: For this particular question, I am not concerned about checking if the form is completely filled out. That is the easy part. If I’m thinking correctly, that is only a matter of checking if each $_POST variable is set.
0
I have an asp.net website that uses ajax and javascript.

I changed the javascript variable name but when i run the website and view the code i see the old vairable name. How do i get the progarm to use the new information.

I tried clearing the cookies and press f5
0
Concerto Cloud for Software Providers & ISVs
LVL 4
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Hi,

My button don't work but alert work after success, what should I do ?


<!DOCTYPE html>
<html lang="fr">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/gif" href="img/drapeauBruxelles.gif" />
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/style.css">
    <title>Projet Map</title>
    <style>
       #map {
        height: 600px;
        width: 90%;
       }
    </style>
  </head>
  <body>
    <div class="container-fluid bg-2 text-center">
      <h1 class="margin">Des Marqueurs Google Maps</h1>
    </div>
    <div id="map"></div>
    <nav class="navbar navbar-default">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="https://developers.google.com/maps/documentation/javascript/adding-a-google-map?hl=fr">My Google Maps</a>
        </div>
        <div class="collapse navbar-collapse" id="myNavbar">
          <ul class="nav navbar-nav navbar-right">

            <li><button type="button" id="btn1">Fontaine d'eau</button></li>
            <li><button type="button" onclick="actionImmediate();">Fontaine d'eau</button></li>
   

Open in new window

0
Hi Following advise from here I'm attempting to build my table using Datatables

In the code bellow I get "TypeError: f is undefined  datatables.min.js (line 60, col 471)" so I'm clearly doing something wrong

I can't just load the data as I need to do stuff, I've added comments, while the data is loading I'm creating a Openlayers marker point (Outside this question scope)

The button is used to simulate the ajax call the table will need to be refreshed

Could someone give me a hand first fixing the error second how to get at & manipulate the data, as commented

<!DOCTYPE html>
<html>
  <head>
    <title>Data Tables</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    	<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.10.15/fc-3.2.2/fh-3.1.2/rr-1.2.0/sc-1.4.2/datatables.min.css"/>
 
<script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.15/fc-3.2.2/fh-3.1.2/rr-1.2.0/sc-1.4.2/datatables.min.js"></script>

<script type='text/javascript'>
	$(function() {
      // jQuery
       $('button').on('click', function (){
          var link = "MOCK_DATA.json";
//          $('#MainTable tbody').html(table);
          

Open in new window

0
Dear experts!

I am experiencing this weird situation as for the first time. I am currently using PHP, html, and JQUERY to design my pages.

I have navbar that direct user to 3 distinctive pages:
1. Home Page
2. inventory
3. Sales

Home page is set as the default page. If select the Inventory option in navbar it will bring me to hte inventory page and same concept applies to sales page.

I am using ajax POST which will pass some values over to the either the inventory or the sales. I was able to navigate from home to inventory or inventory to sales or sales to inventory etc.... without any issue.

But somehow when I hit the F5 or the refresh option in my browser (I am using Chrome and Firefox) it will redirect me back to Home page.

I am wondering why it does that? Doesn't it suppose to stay on the inventory page if I am currently on inventory page?

I tried to trouble shoot here is the strange thing. If I am on Home page and POST to inventory page, I can see my variable that I want to post over to the inventory page ( with the from the $_POST variable and the $_POST variable has a value that tells me what page I am on). If I hit the refresh button or F5, I can see the $_POST value that redirect me to home page instead of the inventory. This kind of trouble me as to why I get redirected back to home instead of staying on the inventory page.
0
Hello Experts,

I am working on a car seat rental program. Upon checking the check boxes of the seats the user wants to rent and clicking the "create rental agreement" submit button, a PDF file is generated which contains all of the renter's information. In addition, the database which contains an inventory of the available seats is updated to remove the seats from the available inventory.

The problem/issue I am running into is:

Upon clicking the "create rental agreement" submit button and then clicking the browser's back button, the rented seats remain checked (see the embedded image).

What is the best way to prevent this from happening? Can I auto refresh the page or eliminate the user's back button? What is the best practice for something like this?

I am open to any ideas.

Already Rented
0
I have a user area where a user can change their password. There is a CSRF token on the form. Once the user submits the form via ajax and the password is successfully changed, I unset the token. This is what I do for non-ajax pages and and then redirect the user on successful submission. But since the user isn't redirecting the session is unset and the token no longer works.

My question is, do I need to unset the session after the password was successfully changed? If so, then what would be the best way to go about it?

In my html, the create token function is called:

 <input type="hidden" name="form_token" id="form_token" value="<?php echo make_form_token(); ?>">

Open in new window


In the ajax submit, validation is performed to check that the session matches the form token.
0
I have a form with a few fields. text & select.. I am POSTing the form AJAX all this seems to be working except for the $_FILES.  In my PHP file I get the value of the file field when I do print_r($_POST); but not when I do print_r($_FILE)

Im expecting got get my textbox and selectbox values in the print_r($_POST);
and get my input type file to display when I print_r($_FILES);

Here is the code
	$("#ApplyChanges").click(function () {
		var fd = new FormData();
		var formErrors = 0;
		$('#girl_info :input[type=text], select, textarea').each(function () {
			if ($.trim(this.value).length >= 1) {
				$(this).css('border-color', '');
				if(this.id == 'language'){
				var languagesArray = [];	
				$("#language option:selected").each(function (i, selectedLanguage) {
					languagesArray[i] = $(selectedLanguage).val();
				});
					fd.append(this.id, JSON.stringify(languagesArray));
				}else{
					fd.append(this.id, this.value);
				}
			}else{
				formErrors++;
				$(this).css('border-color', 'red');				
			}
		});
		
		var counter = 0;
		$('#girl_info :input[type=file]').each(function () {
			if ($.trim(this.value).length >= 1) {
				counter ++;
				fd.append(this.id, this.value);
			}
		});
		
		formErrors = 0; 
		counter = 1;
		
		if(formErrors === 0 && counter >= 1){
			$.ajax({
				type: 'POST',
				enctype: 'multipart/form-data',
				url: '../ajax/form.php',
				data: fd,
				cache: false,
				contentType: false,
				processData: false,
				success: function 

Open in new window

0

AJAX

12K

Solutions

7K

Contributors

Asynchronous JavaScript and XML (AJAX) is a group of interrelated Web development techniques used on the client-side to create asynchronous Web applications. With AJAX, web applications can send data to and retrieve from a server asynchronously (in the background) without interfering with the display and behavior of the existing page. HTML and CSS can be used in combination to mark up and style information. The Document Object Model (DOM) is accessed with JavaScript to dynamically display and allow interaction with the information presented.