Javascript 使用JS执行php url
是否可以简单地用js加载带有url的php脚本Javascript 使用JS执行php url,javascript,jquery,Javascript,Jquery,是否可以简单地用js加载带有url的php脚本 $(function() { $('form').submit(function(e) { e.preventDefault(); var title = $('#title:input').val(); var urlsStr = $("#links").val(); var urls =
$(function() {
$('form').submit(function(e) {
e.preventDefault();
var title = $('#title:input').val();
var urlsStr = $("#links").val();
var urls = urlsStr.match(/\bhttps?:\/\/[^\s]+/gi);
var formData = {
"title": title,
"urls": urls
}
var jsonForm = JSON.stringify(formData);
$.ajax({
type: 'GET',
cache: false,
data: { jsonForm : jsonForm },
url: 'publishlinks/publish'
})
//load php script
});
});
编辑:
function index() {
$this->load->model('NewsFeed_model');
$data['queryMovies'] = $this->NewsFeed_model->getPublications();
$this->load->view('news_feed_view', $data);
}
像这样
$.get('myPHP.php', function(data) {
$('.result').html(data);
alert('Load was performed.');
});
像这样
$.get('myPHP.php', function(data) {
$('.result').html(data);
alert('Load was performed.');
});
简单的
jQuery和:
<script>
$.get('myPHP.php', function(data) {});
</script>
$.get('myPHP.php',函数(数据){});
稍后编辑:
对于表单使用序列化:
<script>
$.post("myPHP.php", $("#myFormID").serialize());
</script>
$.post(“myPHP.php”,$(“#myFormID”).serialize();
简单
jQuery和:
<script>
$.get('myPHP.php', function(data) {});
</script>
$.get('myPHP.php',函数(数据){});
稍后编辑:
对于表单使用序列化:
<script>
$.post("myPHP.php", $("#myFormID").serialize());
</script>
$.post(“myPHP.php”,$(“#myFormID”).serialize();
使用jQuery执行服务器端页面有多种方法。每个方法都有自己的配置,至少您必须指定要请求的url
$.ajax
$.ajax({
type: "Get",//Since you just have to request the page
url:"test.php",
data: {},//In case you want to provide the data along with the request
success: function(data){},//If you want to do something after the request is successfull
failure: function(){}, //If you want to do something if the request fails
});
$。获取
$.get("test.php");//Simplest one if you just dont care whether the call went through or not
var data = {};
$.post("test.php", data, function(data){});
$.post
$.get("test.php");//Simplest one if you just dont care whether the call went through or not
var data = {};
$.post("test.php", data, function(data){});
您可以将表单数据作为json对象获取,如下所示
var data = $("formSelector").searialize();//This you can pass along with your request
使用jQuery执行服务器端页面有多种方法。每个方法都有自己的配置,至少您必须指定要请求的url $.ajax
$.ajax({
type: "Get",//Since you just have to request the page
url:"test.php",
data: {},//In case you want to provide the data along with the request
success: function(data){},//If you want to do something after the request is successfull
failure: function(){}, //If you want to do something if the request fails
});
$。获取
$.get("test.php");//Simplest one if you just dont care whether the call went through or not
var data = {};
$.post("test.php", data, function(data){});
$.post
$.get("test.php");//Simplest one if you just dont care whether the call went through or not
var data = {};
$.post("test.php", data, function(data){});
您可以将表单数据作为json对象获取,如下所示
var data = $("formSelector").searialize();//This you can pass along with your request
你说的负载是什么意思?AJAX有什么问题?加载URL对您的理解是什么?你预计会发生什么?你想做什么?@Felix Kling php的urlscript@amiawizard当前位置这并不能完全回答我的问题,我已经理解了这一点。如果您提供更多信息,您将得到更好的答案。您可以通过从服务器请求来运行资源,从而执行PHP脚本。您的意思是如何在浏览器中触发指向PHP页面的表单提交?什么是加载?AJAX有什么问题?加载URL对您的理解是什么?你预计会发生什么?你想做什么?@Felix Kling php的urlscript@amiawizard当前位置这并不能完全回答我的问题,我已经理解了这一点。如果您提供更多信息,您将得到更好的答案。您可以通过从服务器请求来运行资源,从而执行PHP脚本。您的意思是如何在浏览器中触发指向您的PHP页面的表单提交?您确定要执行它吗?对我来说,它只是向url发送一个get请求。一旦url被点击,该url中的代码就会执行,就像PHP代表预处理超文本一样…在我执行的脚本中,有一个视图假设要加载,为什么不加载?向url发送get请求会导致url中的脚本执行。你确定要执行它吗?对我来说,它只是向url发送一个get请求。一旦url被点击,url中的代码就会执行,就像PHP代表预处理超文本一样……在我执行的脚本中,有一个视图应该被加载,为什么不加载呢?向url发送get请求会导致url中的脚本执行。