我想在调用DOM后重定向。这是我的脚本。
<script>
$(document).ready(function(){
$.get("<?php echo $url; ?>", function(data, status){
alert(data);
});
});
</script>但我想这样做,这样行不通,谁能帮帮我。我更新了我的coding.If,我使用了window.location.href='trip_details.php‘,但警告框不工作。
$username="cde-stng";
$password="12345666";
$msg="Welcome To Safetrip Nigeria";
$url="http://121.241.242.114:8080/bulksms/bulksms?username=".$username."&password=".$password."&type=0&dlr=1&destination=".$mobile."&source=".$mobile."&message=".$msg;
<script>
$(document).ready(function(){
$.get("<?php echo $url; ?>", function(data, status){
//alert(data);
window.alert('Trip Closed');
window.location.href='trip_details.php';
});
});
</script>发布于 2016-03-14 14:20:54
您将在函数之间添加alert()。
删除此行window.alert('Trip Closed') window.location.href='trip_details.php';
然后添加这个
window.location.href='trip_details.php';
发布于 2016-03-14 14:24:56
这个$url和$.get在这里有什么用呢?请让我知道你到底想在这里实现什么。
据我所知,当您加载DOM时,您希望显示警告消息"Trip Closed",然后重定向到trip_details.php。如果是这样,就不需要这个$.get了。
你可以试试这个:
$(document).ready(function(){
alert("Trip Closed");
window.location.href='trip_details.php';
});希望这能有所帮助。
安息吧!xD
发布于 2016-03-14 14:35:42
我没看到你的代码有任何问题。您应该研究一下AJAX请求。您可以尝试使用PostMan来执行GET请求,并检查返回的内容。
如果有与访问控制相关的错误,您可以使用dataType: 'jsonp'处理您的请求。这解决了我在开发Google API时遇到的问题。
尝试使用以下命令在控制台中记录从服务器返回的数据:
$.ajax({
method: "GET",
url: "<?php echo $url; ?>",
dataType: 'jsonp'
}).done(function(data){
console.log(data);
});如果没有错误,您可以尝试这样做:
$.ajax({
method: "GET",
url: "<?php echo $url; ?>",
dataType: 'jsonp'
}).done(function(data){
alert( "Trip Closed" );
window.location.href='trip_details.php';
});https://stackoverflow.com/questions/35980687
复制相似问题