I am have an ajax command in my java script and it works great with all hard coded values. How do it get it to work with a variable value? I have tried create the URL as a variable and entering ajax(variable) which included the complete URL
This works:
var responseText = ajax("http://as400.bass-net.com:10088/testbs/ ... ewcont=109");
This does not work:
var container = 109
var myajax = '"http://as400.bass-net.com:10088/testbs/ ... p?newcont=' + container + '"';
var responseText = ajax(myajax);
Thanks
bill
ajax url
-
- Profound User
- Posts: 22
- Joined: Fri Aug 09, 2013 2:11 pm
- First Name: Bill
- Last Name: Sinclair
- Company Name: Bepco Inc
- Phone: 817-339-7429
- Address 1: 201 Main St
- City: Fort Worth
- State / Province: Texas
- Zip / Postal Code: 76106
- Country: United States
- Contact:
-
- New User
- Posts: 1
- Joined: Mon Mar 03, 2014 7:34 pm
- First Name: Kai
- Last Name: Barrus
- Company Name: Dealertrack Technologies
- Contact:
Re: ajax url
I think your issue may be in how you're building the myajax URL. The following works for me (same request sent, same response):
You don't need to have quotes around the whole URL string. By adding the extra quotes the browser is probably trying to send the ajax request to that resource on the current path (when I try, the ajax request tries to go to http://<my IBM i>/%22http://md5.jsontest.com/?text=109%22 -- the " characters get url encoded to %22).
Code: Select all
var responseText = ajax("http://md5.jsontest.com/?text=109");
console.log(responseText);
var to_md5 = 109;
var ajax_url = "http://md5.jsontest.com/?text=" + to_md5;
var responseText2 = ajax(ajax_url);
console.log(responseText2);
-
- Profound User
- Posts: 22
- Joined: Fri Aug 09, 2013 2:11 pm
- First Name: Bill
- Last Name: Sinclair
- Company Name: Bepco Inc
- Phone: 817-339-7429
- Address 1: 201 Main St
- City: Fort Worth
- State / Province: Texas
- Zip / Postal Code: 76106
- Country: United States
- Contact:
Re: ajax url
thanks again for your help
Who is online
Users browsing this forum: No registered users and 2 guests