This ajax code is only working sometimes. Please solve my problem:
App.controller('sendemail', function (page) {
$.ajax({
type: 'GET',
url: 'http://sanjuwebworks.com/content/9-mobileapps/sendemail.php?callback=response',
// data to be added to query string:
data: { name: 'Zepto.js' },
// type of data we are expecting in return:
dataType: 'jsonp',
timeout: 300,
context: $('body'),
success: function(data){
// Supposing this JSON payload was received:
// {"project": {"id": 42, "html": "<div>..." }}
// append the HTML to context object.
alert(data.success)
console.log('success',data)
},
error: function(xhr, type){
alert('Ajax error!')
}
})
Only sometimes it's alerting and logging to the console,mostly it does not respond.