Ajax函数未触发

时间:2018-08-11 14:04:14

标签: javascript jquery ajax spring-mvc

  

该代码运行到alert(“ name” + name +“ type” + type)并成功警告用户输入,但是在此代码中有语法错误或者我丢失了某些内容或正在执行操作时,它不执行ajax函数诸如缺少$或$(function())之类的错误之类的东西,这些都是ajax获得执行的要求

function myfunction() {

        var checkedName = document.querySelector('input[name="case-type"]:checked'),
        checkedType = document.querySelector('input[name="state-name"]:checked'),
        name = checkedName ? checkedName.value : "Nothing selected",
        type = checkedType ? checkedType.value : "Nothing selected"
    alert("name"+ name + "Type" + type);

$.ajax({// defining the below function as ajax responsive//
    url:'TypeState', // the function that process the  mapped url name and matching type is going to receive the data//
    type:'POST',
    data:{state_name:name,case_type:type},// function to get the value from jsp page and send it to mapped class function//
    success: function(response){// if the backend process is success then the function will run by getting the response as its parameter//
            alert(response.message);

0 个答案:

没有答案
相关问题