jQuery的GET请求的HTTP URL [英] jQuery Get Request on HTTP URL
问题描述
我最近试图让从使用jQuery的URL一些响应。所以我复制 jQuery的API Get请求教程的GET请求样品到我的项目,并试图逃跑它,但我的调试消息给我看,它不能走得更远。我尝试了JavaScript的Ajax库使用一个简单的请求,但没有奏效。
i've recently tried to get some Response from an URL using jQuery. Therefore I copied a get request sample of jQuery API Get Request Tutorial into my project and tried to run it, but my debugging messages showed me, that it can't go further. I tried the javascript Ajax Library using a simple request, but it didn't work.
所以,我在问你,如果你能帮助我莫名其妙。
So i'm asking you, if you could help me somehow.
这就是所有我做什么,但没有任何反应。
And this is all what i do, but there is no response.
var url = "http://www.google.com";
$.get(url, function(data){
alert("Data Loaded: " + data);
});
难道我可能忘了,包括一个AJAX或jQuery库。为了更好地理解,我有c和OBJ-C的遭遇,这就是为什么我认为,一个图书馆丢失。
Did i probably forgot to include a ajax or jQuery library. For a better understanding, i have c and obj-c experince, this is why i think, that a library is missing.
在每个样品也只是很短的网址,如test.php的。是我的完整的HTTP URL错了吗?
In each sample there is just a short url like "test.php". Is my complete HTTP url wrong?
谢谢您的回答中晚期。
溴 尼克
推荐答案
我提供了一个示例场景,以帮助您开始:
I have provided an example scenario to help get you started:
<!-- Include this jQuery library in your HTML somewhere: -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script
这可能是最好的,包括内外部JS文件中:
This is probably best to include inside of an external JS file:
//Listen when a button, with a class of "myButton", is clicked
//You can use any jQuery/JavaScript event that you'd like to trigger the call
$('.myButton').click(function() {
//Send the AJAX call to the server
$.ajax({
//The URL to process the request
'url' : 'page.php',
//The type of request, also known as the "method" in HTML forms
//Can be 'GET' or 'POST'
'type' : 'GET',
//Any post-data/get-data parameters
//This is optional
'data' : {
'paramater1' : 'value',
'parameter2' : 'another value'
},
//The response from the server
'success' : function(data) {
//You can use any jQuery/JavaScript here!!!
if (data == "success") {
alert('request sent!');
}
}
});
});
这篇关于jQuery的GET请求的HTTP URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!