0

i wanted to know that can we send a request using ajax.like can we use domain name with file in URL property of ajax? if no then what to use instead of this ?

$.ajax({
    url:'http://www.domain.com/myfile.php',
})

thank you

enter image description here

adeel pervaiz
  • 65
  • 2
  • 7

2 Answers2

0

Yes, the url can be a full url or a relative one.

jQuery.ajax() documentation has some examples of that.

Hicaro
  • 687
  • 2
  • 8
  • 21
0
  1. Try to use the code below (taken from this repose)
  2. Verify console in your browser dev tools (press F12 in chrome), probably there is an error

 

$.ajax({
  type: "POST",
  url: "http://www.domain.com/myfile.php",
  success: function(msg){
      alert( "Data Saved: " + msg );
  },
  error: function(XMLHttpRequest, textStatus, errorThrown) {
      alert("some error");
  }
});
Community
  • 1
  • 1
Damian
  • 2,752
  • 1
  • 29
  • 28
  • $.ajax({ url:'http://domain.com/data.php', type:'post', success:function(msg){ alert(msg) } }) i used this and nothing happened .. it should show a alert with ok – adeel pervaiz Dec 22 '16 at 23:56