Ajax call failing. Using Jquery .ajax function to make simple request
Here is the jquery to call the ajax function:
function sendAjax(type, succ){ //where succ is the success callback
if (type=="")
{
$("#txtResp").empty();
return;
}
if(succ === undefined) { succ = null; }
switch(type)
{
case 'run':
$.ajax({type:"GET",
url: "start_mess.php",
data: "q="+type,
开发者_JAVA百科 success: succ
});
break;
}
}
Here is the index.html page content:
function initialLoad()
{
sendAjax('run')
$("#txtResp").html(responseText);
}
initialLoad();
Here is the PHP page:
echo $_GET['q'];
$q = $_GET['q'];
Any Idea why this is not working? Thank you!
Taylor
You are not passing a callback, so there is nothing to call on success.
Try sendAjax('run', function(data) { alert(data) });
.
精彩评论