I need the ability to drag and drop a URL (from the url bar in a browser) into a web page, make a request to a web service using that link, and take the JSON reply and populate a form.
I have been able to create the web service that processes the link, and I have been able to use jQuery.ajax to make requests, but I am unsure as to how to interact with a dropped link.
Can anyone point me to an example of this? What should I use?
Edit:
I have been able to fire off my ajax query using "drop", but I am unsure about how to get the value of the URL that I have dropped. Here is my code:
jQuery(function() {
$("input").bind("drop", function(e){
var val = e.dataTransfer.getData('Text')
$.ajax({
type: 'GET',
url: 'http://dev.null:8888/gud/',
data: 'url=' + val,
dataType: 'json',
success: function(jsonData) {
alert(jsonData);
},
error: function (xhr, ajaxOptions, thrownError){
alert("this isnt working");
},
});
});
});
I thought that e.dataTransfer.getData('Text')
would let me access the URL's value, but it doesn't. Does anyone know how I can access that value?
Found it. It is e.originalEvent.dataTransfer.getData('Text')