I want to redirect after call the DOM. This is my script.
<script>
$(document).ready(function(){
$.get("<?php echo $url; ?>", function(data, status){
alert(data);
});
});
</script>
But I want to do like this.It's not working can anyone help me. Iupdated my coding.If i use window.location.href='trip_details.php' and alert box its not working.
$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>
You are adding alert()
between the function.
Remove this line window.alert('Trip Closed') window.location.href='trip_details.php';
and then add this
window.location.href='trip_details.php';
What's the use of this $url and $.get here? Please let me know what exactly you're trying to achieve here.
From what I understand, when you load the DOM, you want to show the alert message "Trip Closed", and then redirect to the trip_details.php. If so, there's no need ot this $.get.
You could try this:
$(document).ready(function(){
alert("Trip Closed");
window.location.href='trip_details.php';
});
Hope this helps.
Peace! xD
I don't see any problem with your code. You should look into the AJAX request. You can try PostMan to perform a GET request and check what gets returned.
If there is error related to Access Control you can use dataType: 'jsonp'
to your request. This solved my problem when I was working on Google API.
Try this to log the data returned from the server in console:
$.ajax({
method: "GET",
url: "<?php echo $url; ?>",
dataType: 'jsonp'
}).done(function(data){
console.log(data);
});
If there are no errors, you can try this:
$.ajax({
method: "GET",
url: "<?php echo $url; ?>",
dataType: 'jsonp'
}).done(function(data){
alert( "Trip Closed" );
window.location.href='trip_details.php';
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.