load()
の代わりにajax()
を使用してください。
このようにして、URLにdata
オプションを設定できます。ここdata
の説明は次のとおりです。
などについては
"Data to be sent to the server. It is converted to a query string, if not already a string. It's appended to the url for GET-requests. See processData option to prevent this automatic processing. Object must be Key/Value pairs. If value is an Array, jQuery serializes multiple values with same key based on the value of the traditional setting (described below)."
:
$.ajax({
url:"http://www.macrumors.com/mr-toggleMobile.php",
data:"mobile=1",
error: function(jqXHR, textStatus, errorThrown){
//textStatus is the error text, like timeout or abort
},
success:function(data){
//data is the downloaded page. Make your stuff here
}
});
あなたは時々あなたは、どちらか一方を必要とするので、あなたは機能を作ることができる:
function getData(var){
$.ajax({
url:"http://www.macrumors.com/mr-toggleMobile.php",
data:"mobile="+var,
error: function(jqXHR, textStatus, errorThrown){
//textStatus is the error text, like timeout or abourt
return "Error: "+textStatus;
},
success:function(data){
//data is the downloaded page. Make your treatment here
return data;
}
});
}
その後あなたは次のように電話します:
var newsPage = getData(1); //1 for mobile, 0 for normal
//do whatever you need with newsPage, like a if for checking if came starting with 'Error'. If not, then seems ajax was successful.
詳細とオプションについては、$.ajax() at jQuery's API Page