php - jQuery Ajax request is only working with one parameter -
i have problem using ajax php file.
used code:
function deleteimage() { $.ajax({ type : 'get', url : '../includes/deleteimage.php', contenttype : 'application/x-www-form-urlencoded', data : { method : "deleteimage", id : "1" }, success : function(msg) { console.log(msg); }, failure : function(msg) { console.log(msg); } }); }
it doesn't work , chrome console showing me following error:
get http://localhost/mypage/webcontent/includes/deleteimage.php?method=deleteimage&id=1
okay, looks missing file. when leaving id parameter out, request works without problem.
i tried different parameter names , plain xmlhttprequest without jquery.
the same error code shown above.
an other request same structure working without problem. (http://localhost/mypage/webcontent/includes/jslistener.php?method=showmainsiteeditor&id=4
)
my local server xampp , i'm testing in google chrome.
your code working perfect on end both post , method try give full url in method
function deleteimage() { $.ajax({ type : 'get', url: "includes/ajax_response.php", contenttype : 'application/x-www-form-urlencoded', data : { method : "deleteimage", id : "1" }, success : function(msg) { alert(msg); console.log(msg); }, failure : function(msg) { console.log(msg); } }); }
and ajax_response.php
if($_request['method']=='deleteimage') { echo $_request['method'].$_request['id']; }
Comments
Post a Comment