jQuery replace url in quotes with a string variable
Can I use a string and substitute it for the quotes where the arrow is pointing below?
$(document).ready(function(){ $.ajax({ type: "GET", url: "http://mydomain/test.xml", <---- Right here can I use a variable like str dataType: "xml", success: function(xml){ etc..开发者_运维知识库.
Yes, you can:
$(document).ready(function(){
var ajaxUrl = "http://mydomain/test.xml";
$.ajax({
type: "GET",
url: ajaxUrl, <---- Right here can I use a variable like str
dataType: "xml",
success:
function(xml){
etc...
You mean like:
$(document).ready(function(){
var someUrl = "http://mydomain/test.xml";
$.ajax({
type: "GET",
url: someUrl,
dataType: "xml",
success:
function(xml){
etc...
精彩评论